我在这条路径中有一个包'My_Package'
/proj/users/Rbud/packrat/lib/x86_64-pc-linux-gnu/3.2.3/My_Package
我正在尝试通过安排cronjob来执行Rscript。 每次cronjob运行时都会出现以下错误
Error in eval(expr, envir, enclos) :
could not find function ".getNamespace"
In addition: Warning message:
package 'My_Package' was built under R version 3.2.3
Error : unable to load R code in package 'My_Package'
Error: package/namespace load failed for 'My_Package'
Execution halted
以下是我的Rscript代码的一部分:
#!/usr/bin/Rscript
#========================================================================
##clear the memory
rm(list = ls())
##these are the settings for the 'My_Package' local rlib.
lib_path1 = "/proj/users/Rbud"
lib_path2 = "packrat/lib/x86_64-pc-linux-gnu/3.2.3"
## Load the My_Package package
Rlocal_lib = file.path(lib_path1,lib_path2)
.libPaths(c(.libPaths(),Rlocal_lib))
library("My_Package",lib.loc = file.path(lib_path1,lib_path2))
library(hash,lib.loc = file.path(lib_path1,lib_path2))
library(RJDBC,lib.loc = file.path(lib_path1,lib_path2))
##The code continues....
我尝试了包括
install.packages(My_Package, lib = "/proj/users/Rbud/packrat/lib/x86_64-pc-linux-gnu/3.2.3/")
在Rscript代码中但我无法解决问题。
您能否告诉我为什么会收到此错误以及解决此问题的可能方法。