Rscript 问题 - 使用不同版本的 R?
我正在尝试在 Rscript 中加载库,但它给了我一个奇怪的错误。我正在运行 2.12.1 版本的 Rscript 二进制文件,但它抱怨我的包是在版本 2.12.1 下构建的。知道这是怎么回事吗?
[17:55:13 trash] $ ./tmp.R
Loading required package: blah
Error: (converted from warning) package 'blah' was built under R version 2.12.1
[17:55:47 trash] $ cat tmp.R
#!/path/to/R/2.12.1/bin/Rscript --quiet
library(blah)
I'm trying to load a library in an Rscript, but it's giving me a strange error. I'm running the 2.12.1 version of the Rscript binary, yet it complains that my package was built under version 2.12.1. Any idea what's going on here?
[17:55:13 trash] $ ./tmp.R
Loading required package: blah
Error: (converted from warning) package 'blah' was built under R version 2.12.1
[17:55:47 trash] $ cat tmp.R
#!/path/to/R/2.12.1/bin/Rscript --quiet
library(blah)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在@aL3xa 和@Iterator 的评论的帮助下找到了答案。当我运行
whereis Rscript
时,我得到:Rscript: /usr/bin/Rscript /usr/bin/X11/Rscript
这些都不代表我想要使用的 R 安装(本例中的版本 3.2.2) case),它位于
/myinstall/R-3.2.2/bin/
但如果我使用整个路径运行 Rscript 命令,我会强制它使用所需的安装:
/myinstall/R-3.2.2/bin/Rscript tmp.R
运行起来轻而易举。
I figured it out with help from comments by @aL3xa and @Iterator. When I run
whereis Rscript
, I get:Rscript: /usr/bin/Rscript /usr/bin/X11/Rscript
None of those represents the R installation I want to use (version 3.2.2 in this case), which would be located at
/myinstall/R-3.2.2/bin/
But if I run the Rscript command with the whole path, I force it to use the desired installation:
/myinstall/R-3.2.2/bin/Rscript tmp.R
which runs like a breeze.