From edd at debian.org  Tue Feb 11 03:31:40 2014
From: edd at debian.org (Dirk Eddelbuettel)
Date: Mon, 10 Feb 2014 20:31:40 -0600
Subject: [Rd] $new cannot be accessed when running from Rscript and
 methods package is not loaded
In-Reply-To: <52F98292.2090209@ivt.baug.ethz.ch>
References: <52F98292.2090209@ivt.baug.ethz.ch>
Message-ID: <21241.35724.813573.176958@max.nulle.part>


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



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