[R] Rscript question
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Feb 20 08:28:32 CET 2010
On Fri, 19 Feb 2010, Jinfeng Liu wrote:
> OS <oozingslackitude <at> gmail.com> writes:
>> Hi,
>> I have some code I run interactively through the R interpreter and it works
>> fine. I then run it as a script with Rscript and I get an error. The error
>> is coming when Rscript builds a model matrix.
>>
>> Output from Rscript with the error:
>> running
>> '/usr/lib/R/bin/R --slave --no-restore --file=./matchingModel --args
>> mmtest'
>> ...
>
>> Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
>> could not find function "is"
>> Calls: glm ... model.matrix -> model.matrix.default -> contrasts<-
>>
>
> I ran into the same problems. Apparently, Rscript somehow doesn't automatically
> load the 'methods' package. The problem can be solved by adding
>
> library(methods)
>
> in your script.
As documented, of course, including how to control the default
packages from the Rscript command line.
But the bug was the unconditional use of methods in the stats package,
and has been corrected in current versions of R (R-patched and
R-devel). You failed to follow the posting guide and give us the
asked-for 'at a minimum' information about yours. (When you are
re-reading it, see what the posting guide has to say about updating
before posting.)
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list