[R] S4 Package with definition of method 'names'
Thomas Roth (geb. Kaliwe)
hamstersquats at web.de
Thu Jun 11 16:43:31 CEST 2009
Dear List,
Is it possible to build a package with 'names' method for a S4-Class?
The following works if directly pasted into R:
(a simple test class with 1 attribute that is returned by invoking 'names')
#class definition
setClass("test", representation = representation(name = "character"),
prototype = prototype(name = "thisIsMyName"))
#definition of names for class test
setMethod("names", "test", function(x)
{
x at name
}
)
#definition of names<- for class test
setReplaceMethod("names", "test", function(x, value)
{
x at name <- value
x
}
)
test = new("test")
names(test) #returns "thisIsMyName"
However 'R CMD check ' for building a package fails with
Error in setMethod(f, signature, NULL, where = where) :
the method for function "names" and signature ="" is sealed and cannot
be re-defined
Calls: <Anonymous> ... sys.source -> eval -> eval -> removeMethod ->
setMethod
Execution halted
make[2]: *** [lazyload] Error 1
make[1]: *** [all] Error 2
make: *** [pkg-DAP] Error 2
This is somewhat confusing since it works nicely if pasted into R.
Any Ideas
Thank you for your time
Thomas Roth
More information about the R-help
mailing list