首页 > 解决方案 > 调用编译后的 R 函数

问题描述

很抱歉错过了(我确信很明显)文档,但我看不到如何从另一个函数调用已编译的函数。例如,考虑:

compiledFunction <- function(x) {
  return(x+1)
}

在 R 中,运行:

source( '~/compiledFunction.R' )
compiledFunction_cmp <- cmpfun( compiledFunction)
save( compiledFunction_cmp, file='compiledFunction_cmp.?')

然后:

callCompiledFunction <- function() {
  source( <can I load the executable in some way?> )  
  print( compiledFunction_cmp(1) )
}

或者,您是否从不保存可执行文件,而是让外部函数调用'compile ...'?如果是这样,那和即时编译(enableJIT(3))有什么区别?

标签: rcompilation

解决方案


推荐阅读