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.

Reply via email to