运行 R 脚本 - Ubuntu 服务器 [英] Run R Script - Ubuntu Server

查看:57
本文介绍了运行 R 脚本 - Ubuntu 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在 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.

两个修复:

  1. library(methods) 添加到您的脚本中,或
  2. 执行 sudo apt-get install r-cran-littler 并使用 r 而不是 Rscript.
  1. Add library(methods) to your script, or
  2. Do sudo apt-get install r-cran-littler and use r instead of Rscript.

r 从第一天起就一直在加载 methods,因为 Rscript 的这种行为从未真正有意义.

r has been loading methods since day one as this behaviour of Rscript never really made sense.

这篇关于运行 R 脚本 - Ubuntu 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆