petertait at sympatico.ca
2010-Jan-25 15:58 UTC
[R] Rscript is not loading some of one of the standard R packages
Hi, I have a script I can run step by step through the R interpreter and it works fine. I then run as a shell script with Rscript and it fails. The error message comes when I am creating a model matrix with model.matrix.default(). Error in `contrasts<-`(`*tmp*`, value = "contr.Treatment") : could not find function "is" Calls: model.matrix.default -> contrasts<- I included the following command at the beginning of my Rscript : cat("Looking for environment(is): ", environment(is), "\n") and I received the same error message: Error in environment(is) : object 'is' not found Calls: cat -> environment At the command line (through the R interpreter) the same command returns:> environment(is)<environment: namespace:methods> Rscript is not loading the methods package and I don't know how to fix this. Why would this be happening and how can I prevent it in the future? I am running the following R session at the command line:> sessionInfo()R version 2.10.1 (2009-12-14) x86_64-pc-linux-gnu locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base Here is what I get when I run sessionInfo() from Rscript R version 2.10.1 (2009-12-14) x86_64-pc-linux-gnu locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets base The version of Rscript I am running is: $ Rscript --version R scripting front-end version 49838 Thank you for your help Peter [[alternative HTML version deleted]]