我試着按照該指南中http://adv-r.had.co.nz/Rcpp.html瞭解RCPP 但我總是需要運行devtools::find_rtools()
任何RCPP功能的工作原理之前: 如果我做爲什麼我需要在has_devel()= TRUE之前運行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提示我安裝額外的構建工具(但是當我說是時沒有任何反應)。它看起來像一些命令失敗,但system("where make")
給出了我的路徑中的路徑。 當我再做
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 <- 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開始菜單中)更改路徑。 – Thomas
是的,那是來自乾淨的會議。 但是路徑中缺少哪個目錄,Rtools似乎至少有一些目錄? – luoar