Rscript “there is no package”

可紊 提交于 2019-12-11 11:56:06

问题


I have a script that loads data, processes it, and saves the processed data out. I run it manually without a problem, but it does not work with Rscript. It uses the data.table package, and Rscript cannot find it. I have tried the solution here but get the following error message:

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

The script looks like:

#!/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)

That code is after failing with library(data.table). But I can load data.table fine, and so the rest of the script works, if I do this manually. The command I submit to bash is:

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

Session info:

> 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 

which Rscript:

/usr/local/bin/Rscript

/usr/local/bin/R loads data.table fine when it is called in an interactive session.

来源:https://stackoverflow.com/questions/35233574/rscript-there-is-no-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!