[Rd] $new cannot be accessed when running from Rscript and methods package is not loaded

Dirk Eddelbuettel edd at debian.org
Tue Feb 11 03:31:40 CET 2014


On 11 February 2014 at 02:53, Kirill Müller wrote:
| Why does it seem to be necessary to load the methods package here?

"Just use littler (TM pending)".  

It (auto-)load methods automagically, thanks to Jeff Horner.  See below.

   edd at max:~$ chmod 0755 /tmp/kirill.r 
   edd at max:~$ /tmp/kirill.r 
   [1] "refObjectGenerator"
   attr(,"package")
   [1] "methods"
   edd at max:~$ cat /tmp/kirill.r 
   #!/usr/bin/r
   
   newTest <- function() {
      cl <- get("someClass")
      cl$new
   }

   someClass <- setRefClass("someClass")
   print(class(someClass))
   edd at max:~$ 

For Rscript, you still need to load it explicitly like any other packages you
want to use.

Dirk

PS New littler release pending in a few days or weeks. The Github repo is
current and working.

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



More information about the R-devel mailing list