[R] Getting code for functions

Douglas Bates bates at stat.wisc.edu
Mon Sep 27 18:28:35 CEST 2004


Peter Flom wrote:
> Hello
> 
> Pardon for the elementary question, I did try searching the archives
> with various terms, but to no avail.  I am using R1.9.1 on a windows
> machine
> 
> One of the great advantages of R (to me, anyway) is being able to see
> the code for a function , e.g. by typing sd one sees the code for
> getting a standard deviation.
> 
> However, for many functions this only provides info. including
> UseMethod, eg. typing mosaicplot yields
> 
> function (x, ...) 
> UseMethod("mosaicplot")
> <environment: namespace:graphics>
> 
> 
> How can I see the code for such functions?

Any function whose body contains a call to UseMethod is an S3 generic 
function.  To see all the possible methods for the function, use

methods("mosaicplot")

The default method will be called mosaicplot.default and that's probably 
the one you want to examine.




More information about the R-help mailing list