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...@name
}
)

#definition of names<- for class test
setReplaceMethod("names", "test", function(x, value)
{
x...@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

______________________________________________
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