I have a package 'My_Package' in this path
/proj/users/Rbud/packrat/lib/x86_64-pc-linux-gnu/3.2.3/My_Package
I am trying to exectute an Rscript by scheduling a cronjob. Each time cronjob runs I get the following error
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
Here is part of my Rscript code:
#!/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....
I tried with including
install.packages(My_Package, lib = "/proj/users/Rbud/packrat/lib/x86_64-pc-linux-gnu/3.2.3/")
in the Rscript code but I couldn't resolve the issue.
Could you please tell me why I am getting this error and the possible ways to resolve it.