从源代码安装 R 包,无需更改 PATH (Windows)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8042136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install R package from source, without changing PATH (Windows)
提问by screechOwl
I'm trying to install package rpart
for R-2.14.0 on Windows 7, but I get the warning:
我正在尝试rpart
在 Windows 7 上为 R-2.14.0安装软件包,但收到警告:
package ‘rpart' is not available (for R version 2.14.0)
包“rpart”不可用(对于 R 版本 2.14.0)
So I download the tar.gz file from the package page. I have installed Rtools but I disabled all the options, including the one that changes the PATH. Then I do the following:
所以我从包页面下载了 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
Any suggestions?
有什么建议?
回答by Joshua Ulrich
Since you have to set the PATH
, but you're hesitant to do so because you're afraid you may hose something up, you can do it temporarily in your R session via:
由于您必须设置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=";"))