运行 R 脚本 - Ubuntu 服务器 [英] Run R Script - Ubuntu Server
问题描述
我最近在 Ubuntu Server 16.04 上编译了 R.我正在尝试使用 Rscript 函数运行 R 脚本,但遇到了错误.
I've recently compiled R on Ubuntu Server 16.04. I'm attempting to run an R Script using the Rscript function, but I'm running into errors.
当我使用 Rscript
运行脚本时,输出显示函数 as()
和 new()
包含在方法包中无法找到 R 分布.当我以交互方式运行 R 时,我可以毫无问题地使用这些函数.
When I run the script using Rscript
, the output shows the functions as()
and new()
from the methods package included in the R distribution cannot be found. When I run R interactively, I'm able to use these functions without any problem.
任何帮助将不胜感激!
推荐答案
这是Rscript
中的一个设计错误:它不加载方法
启动时.
It is a design bug in Rscript
: it does not load methods
on startup.
两个修复:
- 将
library(methods)
添加到您的脚本中,或 - 执行
sudo apt-get install r-cran-littler
并使用r
而不是Rscript
.
- Add
library(methods)
to your script, or - Do
sudo apt-get install r-cran-littler
and user
instead ofRscript
.
r
从第一天起就一直在加载 methods
,因为 Rscript
的这种行为从未真正有意义.
r
has been loading methods
since day one as this behaviour of Rscript
never really made sense.
这篇关于运行 R 脚本 - Ubuntu 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!