From bullard at stat.Berkeley.EDU  Tue Feb  2 23:12:16 2010
From: bullard at stat.Berkeley.EDU (bullard at stat.Berkeley.EDU)
Date: Tue, 2 Feb 2010 14:12:16 -0800 (PST)
Subject: [Rd] S4 setClass / initialize misunderstanding
Message-ID: <6386.66.201.56.150.1265148736.squirrel@www.stat.berkeley.edu>


Hi, I recently ran into this problem. I couldn't find any mention of it in
the setClass documentation.

setClass("Foo", representation(file = "character"))
setMethod("initialize", "Foo", function(.Object, file) {
  print(file)
})
setClass("Bar", contains = "Foo")

And the error:

Error in print(file) : argument "file" is missing, with no default

The workaround is to interchange the setMethod and the second setClass
call, however, it begs the question why is setClass calling an initialize
method? As always, if I have missed documentation concerning this please
point me there.

Thanks, jim



[Rd] S4 setClass / initialize misunderstanding
bullard at stat.Berkeley.EDU