Re: [R] setMethod

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Fri 22 Sep 2006 - 22:40:01 GMT

On 9/22/2006 4:02 PM, Sender wrote:
> Hello R-help:
>
> I was hoping someone could help me understand a particular function i came
> across in a package:
>
> "$.myClass" <- function( x, name ) {
> sym = paste( "foo", name, sep = "_" )
> if( is.loaded(sym) )
> .Call(sym,x)
> }
>
> I understand the paste, and .Call part, but I'm not sure how this function
> would get called? What exactly is $. ? is it a regular expression? Would a
> user call this method directly, or is it an internal function that gets
> called according to a class/type.

It's the implementation of the "$" function for myClass objects, so if x was a myClass object, it would be called when something like

x$name

was used in an expression. It would call an external function named foo_name, passing x as an argument.

Duncan Murdoch

>
> something similar to:
>
> plot.lm()
>
> Thanks in advance !
>
> Greg
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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
> and provide commented, minimal, self-contained, reproducible code.



R-help@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 and provide commented, minimal, self-contained, reproducible code. Received on Sat Sep 23 08:43:57 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 23 Sep 2006 - 00:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.