Thomas Roth (geb. Kaliwe)
2009-Jun-11 14:43 UTC
[R] S4 Package with definition of method 'names'
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