Depending on what those 700 other lines of code do... By default the initialize
method for S4 classes is a copy constructor, with unnamed arguments taken as instances of base classes. Maybe you mean that you have something like (my classes A, B, C don't correspond to your classes, but somehow the naming seems to make more sense for my understanding of your problem)
.A <- setClass("A", representation(a="numeric"))
.B <- setClass("B", representation(b="numeric"))
.C <- setClass("C", contains=c("A", "B"))
.A(...)
is the automatically generated constructor for the "A" class, etc; .A(...)
creates a new instance of the class "A" and then calls initialize
(i.e., the copy constructor) with the new instance and arguments ...
. One possibility is that you have an instance of "A" and an instance of "B", and you'd like to construct and instance of "C"
a <- .A(a=1)
b <- .B(b=2)
with
> .C(a, b) # Construct "C" from base classes "A" and "B"
An object of class "C"
Slot "a":
[1] 1
Slot "b":
[1] 2
Another possibility is that you already have an instance of "C", and you'd like to update the values to contain those from an instance of "B"
b <- .B(b=2)
c <- .C(a=1, b=3)
and then
> initialize(c, b) # Copy c, replacing slots from 'B' with 'b'
An object of class "C"
Slot "a":
[1] 1
Slot "b":
[1] 2