Correction. My solution didn't work either.... Didn't return the correct values. Can you post an example that takes three arguments? I'm working on how to do this now. thanks...sorry. I"m new to R and R.oo.
Ben On Mon, Aug 29, 2011 at 8:35 AM, Ben qant <ccqu...@gmail.com> wrote: > Henrik, > > Your last suggestion did not work for me. It seems like it does not allow > me to create a ClassB object with 3 arguments: > > > > setConstructorS3("ClassA", function(A=15, x=NA) { > + extend(Object(), "ClassA", > + .size = A, > + .x=x > + ) > + }) > > setConstructorS3("ClassB", function(..., bData=NA) { > + extend(ClassA(...), "ClassB", > + .bData = bData > + ) > + }) > > b = ClassB(1,2,3) > Error in ClassA(...) : unused argument(s) (3) > > I got around it using your 'specific' suggestion: > > > > setConstructorS3("ClassA", function(A=15, x=NA) { > + extend(Object(), "ClassA", > + .size = A, > + .x=x > + ) > + }) > > > > setConstructorS3("ClassB", function(..., bData=NA) { > + extend(ClassA(A=15,x=NA), "ClassB", > + .bData = bData > + ) > + }) > > b = ClassB(1,2,3) > > > > > [[alternative HTML version deleted]] ______________________________________________ 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.