[Rd] problem subsetting of a reference class

From: A Zege <andre.zege_at_gmail.com>
Date: Thu, 21 Apr 2011 12:24:11 -0700 (PDT)

I am trying to define subset operator for a reference class and hitting some problem i am unable to diagnose.To give an example, here is a toy class generator that is a wrapper around a list

tmpGEN<-setRefClass("TMP", fields=list(

tmpGEN$methods('add'=function(obj, name){



				stop('to return cache element need to pass its name')
			ind<-match(name, names(namelist))
				stop('data to remove is not in namelist')

when i try to use it, the following happens v<-rnorm(10)
tmp$add(v, 'random')

..... up until here everything is ok, class is generated and vector is added. Now when i do

i get error message

Error in tmp["random"] : object of type 'S4' is not subsettable

Not sure if it means that i cannot define "[" operator for a class or if i am doing it syntactically wrong

View this message in context: http://r.789695.n4.nabble.com/problem-subsetting-of-a-reference-class-tp3466690p3466690.html
Sent from the R devel mailing list archive at Nabble.com.

R-devel_at_r-project.org mailing list
Received on Thu 21 Apr 2011 - 19:30:00 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 Fri 22 Apr 2011 - 02:10:52 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive