[R] Method for $
Uwe Ligges
ligges at statistik.uni-dortmund.de
Fri Nov 18 17:45:40 CET 2005
Ulrike Grömping wrote:
> 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 object at slotname, 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){
> x at slotname
> }
> )
Ulrike,
what about (untested!):
slot(x, slotname)
Best wishes from Dortmund and Lena,
Uwe Ligges
> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list