Thanks Henrik! Adding the line library("methods")
to the list of required libraries did indeed solve the problem. My next comment will show my naivety when it comes to R dependency management, but I noticed that including `library("rJava")` in place of methods also solves the problem. This confuses me because I would think that RWeka depends on rJava so I don't understand why transitive dependencies wouldn't automatically be loaded -- something for me to research more when I have the chance. Thanks for the help -- sadly it took me a month to see it as these responses were automatically diverted to a folder using filter logic I set up a few years ago and forgot about... On Wed, Nov 19, 2014 at 2:57 PM, Henrik Bengtsson <h...@biostat.ucsf.edu> wrote: > When using Rscript, the 'methods' package is not loaded/attached by > default, which it is when you use R. See ?Rscript for details. For > any scripts intended for batch usage, the safest is to only assume > that 'base' is attached, but nothing else. > > /Henrik > > On Wed, Nov 19, 2014 at 10:03 AM, Ben Tupper <ben.bigh...@gmail.com> > wrote: > > Hi, > > > > On Nov 19, 2014, at 11:48 AM, Jeff Hansen <dsche...@gmail.com> wrote: > > > >> I have a script that uses RWeka (and consequently rJava). When I run > >> it in Rstudio everything works fine. When I run it with `R CMD BATCH`, > >> everything also works fine. However, when I run it with Rscript, I get > >> the following error: > >> > >> Error in FUN(X[[1L]], ...) : > >> object is not a Java object reference (jobjRef/jarrayRef). > >> Calls: evaluate_Weka_classifier -> t -> sapply -> lapply -> FUN > >> Execution halted > >> > >> The following is a very simple toy script that you can run to produce > >> the results: > >> > >> library("RWeka") > >> result <- c(TRUE,FALSE,TRUE,FALSE,TRUE) > >> observation <- c(TRUE,FALSE,TRUE,FALSE,TRUE) > >> df <- data.frame(result,observation) > >> j48 <- J48(result ~ .,data=df) > >> evaluate_Weka_classifier(j48) > >> > >> Save that to a file called help.R and run > >> > >> R CMD BATCH help.R > >> > >> Check the output file help.Rout and you should see no errors. Now try > >> running it from: > >> > >> Rscript help.R > >> > > > > You might try using the the --vanilla option for each. At least then > you can rule out that something is being restored in the session of one but > not the other. > > > > R --vanilla CMD BATCH help.R > > Rscript --vanilla help.R > > > > Cheers, > > Ben > > > > > >> And you should see the error I've pasted above. > >> > >> I have consulted (and will continue to consult) the literature, but > >> the manuals tend to answer how usage differs between the two commands > >> rather than going into implementation details. I imagine there's a > >> difference in how environments get loaded and I just need to adjust > >> something on the Rscript side. > >> > >> I'm working on a Mac (OSX) running R 3.1.0, but I get the same results > >> when I run everything from a Centos 6.4 virtual machine (headless) > >> with R 3.1.1 installed. > >> > >> Thanks for any help! > >> > >> ______________________________________________ > >> R-help@r-project.org mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > >> and provide commented, minimal, self-contained, reproducible code. > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.