R脚本从命令行 [英] R script from command line

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

问题描述

我想运行此示例脚本: http://mazamascience.com/WorkingWithData/?p= 912 从Windows命令行。所以我打开命令行并键入 Rscript tryCatch.R 1 。但是,我一直收到错误消息错误:R not found 。我设置PATH环境变量为 C:\Programme\R\R-3.0.1\bin 。如果我只输入 R.exe ,它会启动 R ,但它找不到要加载的包(例如未找到选项<defaultPackages>中的package'utils')。我想我必须设置另一条路径到图书馆某处,但我不知道在哪里做这个。

I wanted to run this example script: http://mazamascience.com/WorkingWithData/?p=912 from Windows command line. So I opened the command line and typed Rscript tryCatch.R 1. However, I keep getting the error message Error: R not found. I did set the PATH environment variable as C:\Programme\R\R-3.0.1\bin. If I just type R.exe, it does start R, but it cannot find the packages that are to be loaded at start (e.g. package 'utils' in options<"defaultPackages"> was not found). I guess I have to set another path to the libraries somewhere, but I haven't got any idea where to do this.

更新:显式键入 PATH C:\Programme\R\R-3.0.1\bin (而不是仅仅将其添加到环境变量PATH的值),似乎 R 。但是,会出现一个新问题:在normalizePath< path.expand(path),winslash,mustWork> ;:path [2] =C:/Programme/R/R-3.0.1/library:访问被拒绝,与方法库相同。然后:调用:.First ...库 - > .getRequiredPackages2 - >库 - > normalizePath执行已停止。我使用的是Windows 7,我有管理员权限。

UPDATE: After explicitly typing PATH C:\Programme\R\R-3.0.1\bin (rather than just adding this to the value of the environment variable PATH) it seems that R is found. However, a new problem occurs: In normalizePath<path.expand(path), winslash, mustWork>: path[2] = "C:/Programme/R/R-3.0.1/library": Access denied, the same than for the methods library. Then: Calls: .First ... library -> .getRequiredPackages2 -> library -> normalizePath Execution stopped. I'm using Windows 7 and I do have administrator rights.

推荐答案

我发现它是一种特定语言问题,类似于此处所述: https:/ /stat.ethz.ch/pipermail/r-help/2011-May/276932.html

I've found out that it was a language-specific problem on Windows 7, similar to what is described here: https://stat.ethz.ch/pipermail/r-help/2011-May/276932.html

更改 PATH

After changing PATH to C:\Program Files\R\R-3.0.1\bin the script is properly executed from the command prompt.

感谢所有尝试帮助的人!

Thanks to everyone who tried to help!

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

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