Re: [Rd] R5 reference classes: how to initialize exactly?

From: Janko Thyson <>
Date: Tue, 16 Nov 2010 00:30:28 +0100

Sorry, I was stupid:  

MyRefObj <- setRefClass("Blabla", .)  

One can always get the generator object of an defined class with
'getRefClass()'. So:

g <- getRefClass("Blabla")

x <- g$new(.)  



Von: Janko Thyson [] Gesendet: Dienstag, 16. November 2010 00:27 An: 'r-devel_at_r-project. org'
Betreff: R5 reference classes: how to initialize exactly?  

Dear List,  

So far, I really like those new R5 classes. But what kind of puzzles me is that it's not just enough to define the actual reference class, I also have to assign it to an object (e.g. 'MyRefObj') in order to fire


setClass("Blabla", .)

x <- new("Blabla")  


MyRefObj <- setRefClass("Blabla", .)

x <- MyRefObj$new(.)  

But then how do I define a reference class in a package that should be available after the package is loaded via 'library(my_pkg)' as there is no
'MyRefObj' at startup yet? Do I have to call the script where the definition

Thanks for any comments,


        [[alternative HTML version deleted]] mailing list Received on Mon 15 Nov 2010 - 23:35:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 17 Nov 2010 - 10:50:21 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive