Rscript“没有包”

时间:2016-02-05 21:10:40

标签: r data.table rscript

我有一个加载数据,处理数据并保存已处理数据的脚本。我手动运行没有问题,但它不适用于Rscript。它使用data.table包,而Rscript找不到它。我尝试了the solution here,但收到以下错误消息:

Error in eval(expr, envir, enclos) :   could not find function ".getNamespace" 
In addition: Warning message: package ‘data.table’ was built under R version 3.1.1 Error : unable to load R code in package ‘chron’ 
Error: package/namespace load failed for ‘data.table’
Execution halted

脚本如下:

#!/usr/local/bin/Rscript
args = commandArgs(trailingOnly = TRUE)  # Take arguments from command line
library.path <- '/home/zack/R/x86_64-redhat-linux-gnu-library/3.1'
library('data.table', lib.loc = library.path)

该代码是在使用库(data.table)失败之后。但我可以加载data.table,所以如果我手动执行此操作,其余的脚本都可以正常工作。我提交给bash的命令是:

nohup /usr/local/bin/Rscript --vanilla <path to script> <args> &

会话信息:

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-redhat-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base 

哪个Rscript:

/usr/local/bin/Rscript

/ usr / local / bin / R在交互式会话中调用data.table时会加载。

0 个答案:

没有答案