从源代码安装R包,无需更改PATH(Windows)

时间:2011-11-07 20:22:45

标签: windows r

我正在尝试在Windows 7上为R-2.14.0安装软件包rpart,但我收到警告:

  

包'rpart'不可用(对于R版本2.14.0)

所以我从包页面下载tar.gz文件。我已经安装了Rtools但是我禁用了所有选项,包括更改PATH的选项。然后我做以下事情:

> install.packages("C:/rpart_3.1-50.tar.gz", type="source")
Installing package(s) into ‘C:/Users/backupSam/Documents/R/win-library/2.14’
(as ‘lib’ is unspecified)
inferring 'repos = NULL' from the file name
* installing *source* package 'rpart' ...
** libs

*** arch - i386
ERROR: compilation failed for package 'rpart'
* removing 'C:/Users/backupSam/Documents/R/win-library/2.14/rpart'
* restoring previous 'C:/Users/backupSam/Documents/R/win-library/2.14/rpart'
Warning messages:
1: running command 'C:/PROGRA~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l "C:/Users/backupSam/Documents/R/win-library/2.14"   "C:/rpart_3.1-50.tar.gz"' had status 1 
2: In install.packages("C:/rpart_3.1-50.tar.gz", type = "source") :
  installation of package ‘C:/rpart_3.1-50.tar.gz’ had non-zero exit status

有什么建议吗?

1 个答案:

答案 0 :(得分:8)

因为你必须设置PATH,但是你因为害怕你可能会软化某些东西而犹豫不决,你可以通过以下方式暂时在你的R会话中这样做:

pathRtools <- paste(c("c:\\Rtools\\bin",
  "c:\\Rtools\\MinGW\\bin",
  "c:\\MiKTeX\\miktex\\bin",
  "c:\\R\\bin\\i386",
  "c:\\windows",
  "c:\\windows\\system32"), collapse=";")
Sys.setenv(PATH=paste(pathRtools,Sys.getenv("PATH"),sep=";"))