[R] function code

Duncan Murdoch murdoch at stats.uwo.ca
Fri Jan 25 16:06:43 CET 2008


On 1/25/2008 9:46 AM, Luis Ridao Cruz wrote:
> R-help,
> 
> Sorry for this question (I guess it has been addressed before but 
> I could not find it in the archives)
> but how can I see a function code
> when the following comes up:
> 
>> svymean
> function (x, design, na.rm = FALSE, ...) 
> {
>     .svycheck(design)
>     UseMethod("svymean", design)
> }
> <environment: namespace:survey>

That's a call to a generic function; what UseMethod calls depends on the 
class of the design variable.

You can see all the possibilities listed by

methods("svymean")

which on my system shows:

 > methods("svymean")
[1] svymean.survey.design*  svymean.survey.design2* svymean.svyrep.design*
[4] svymean.twophase*

    Non-visible functions are asterisked


When you want to see a "non-visible" function, use getAnywhere(), or if 
you happen to know where it lives, use ":::" notation, e.g.

survey:::svymean.survey.design

Duncan Murdoch



More information about the R-help mailing list