[R] R script doesn't load libraries when called from cron
zerdna
azege at yahoo.com
Fri Aug 6 19:41:48 CEST 2010
I have R script that i need to run in cron. Either R libraries or some .so
libraries that they depend on don't get loaded correctly. Here is an
example. I have a file, call it tmp.R
tmp.R
=========================
R --slave --args $0 $* <<EOF
cmarg = commandArgs()[5]
library(R.utils)
b<-intToBin(cmarg)
print(paste( "argument is ", cmarg, sep=""))
print(paste(" binary representation of argument is ", b))
===========================================
It loads a library R.utils, uses function intToBin from it, prints binary
rep of the argument. When i run it from command line like
./tmp.R 10
it runs fine. Here is the output:
Output:
==============================
Loading required package: R.oo
Loading required package: R.methodsS3
R.methodsS3 v1.2.0 (2010-03-13) successfully loaded. See ?R.methodsS3 for
help.
R.oo v1.7.3 (2010-06-04) successfully loaded. See ?R.oo for help.
R.utils v1.4.0 (2010-03-24) successfully loaded. See ?R.utils for help.
Warning message:
package 'R.oo' was built under R version 2.8.1 and help may not work
correctly
[1] "command argument is 10"
[1] " binary representation of argument is 1010"
========================================
Now, here is the problem. When i run it from cron I get error message
====================================================
Error in loadNamespace(name) : there is no package called 'R.utils'
Calls: sys.load.image ... tryCatch -> tryCatchList -> tryCatchOne ->
<Anonymous>
Execution halted
====================================================
seemingly it has problems with loading library, but i cannot figure out why.
I tried running it using Rscript program, R CMD BATCH, calling R directly
and i always run into the same problem when called from cron.
I am running 64 bit R v10 on 64 Red Hat Lunix.
--
View this message in context: http://r.789695.n4.nabble.com/R-script-doesn-t-load-libraries-when-called-from-cron-tp2316594p2316594.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list