【发布时间】:2016-09-10 15:12:59
【问题描述】:
我尝试按照http://adv-r.had.co.nz/Rcpp.html 中的指南来了解 Rcpp
但我总是需要在任何 Rcpp 函数起作用之前运行devtools::find_rtools():
如果我这样做了
library(devtools)
library(Rcpp)
has_devel() # Error: Command failed(1)
# Example from http://adv-r.had.co.nz/Rcpp.html
add <- cppFunction('int add(int x, int y, int z) {
int sum = x + y + z;
return sum;
}')
我收到一个错误,Rstudio 提示我安装其他构建工具(但当我说是时没有任何反应)。看起来某些 make 命令失败了,但 system("where make") 给出了我 PATH 中的路径。
当我这样做时
find_rtools() # True
has_devel() # True
# Try the example again
add <- cppFunction('int add(int x, int y, int z) {
int sum = x + y + z;
return sum;
}')
# Now works
add(1,2,3) # 6
devtools 和 Rcpp 似乎都很高兴。为什么会这样?我该如何解决?
这是我的 PATH 的开始
path <- get_path()
head(path, 8)
[1] "F:\\Software\\R-3.3.0\\bin\\x64"
"F:\\Software\\Rtools\\bin"
[3] "F:\\Software\\Rtools\\gcc-4.6.3\\bin"
"F:\\Software\\Python 3\\Scripts\\"
[5] "F:\\Software\\Python 3\\"
"F:\\Software\\Rtools\\bin"
[7] "F:\\Software\\Rtools\\gcc-4.6.3\\bin"
"C:\\Program Files (x86)\\Intel\\iCLS Client\\"
【问题讨论】:
-
这条路径来自干净的 R 会话吗?
find_rtools()仅修改该会话的路径。如果您希望它永久工作而无需运行 devtools,请通过环境变量对话框(在 Windows 开始菜单中)更改您的路径。 -
是的,这是来自一个干净的会话。但是路径中缺少哪个目录,Rtools 里面好像至少有一些目录?!