Rscript 问题 - 使用不同版本的 R?

发布于 2024-12-13 01:28:16 字数 380 浏览 5 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠栀 2024-12-20 01:28:16

我在@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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文