Dear R experts,
I have defined a class "myclass" and would like the slots to be extractable
not only by "@" but also by "$". I now try to write a method for "$" that
simply executes the request [EMAIL PROTECTED], whenever someone calls
object$slotname for any object of class "myclass".
I don't manage to find out how I can provide this function with "slotname",
so that one and the same function works for any arbitrary slotname a user
might choose.
I have tried
setMethod("$", signature(x="myclass"), function(x,slotname){
[EMAIL PROTECTED]
}
)
This produced the error message:
In method for function "$": expanding the signature to
include omitted arguments in definition: name = "missing"
Error in rematchDefinition(definition, fdef, mnames, fnames, signature) :
methods can add arguments to the generic only if '...' is an argument
to the generic
My searches for a solution of this problem have not been successful. Can
someone help?
Thanks and regards,
Ulrike Grömping, Berlin
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html