[R] function in R
Gustaf Rydevik
gustaf.rydevik at gmail.com
Thu Oct 2 13:53:45 CEST 2008
On Thu, Oct 2, 2008 at 1:34 PM, Alphonse Monkamg <amonkamg at yahoo.fr> wrote:
>
>
>
>
> Dear ALL,
>
> Does anyone know how to get the complete code program for any build-in function
> in R, e.g. when I tape mean in the R-console, I get the following:
>
> mean
>
> function (x, ...)
>
> UseMethod("mean")
>
> <environment: namespace:base>
>
> but I need the full mean function.
>
>
>
> Thank in advance,
>
>
>
> Alphonse.
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org 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.
>
>
Hi Alphonse,
"mean" is a so-called "generic function", that behaves differently
depending on what class it's argument is.
writing:
?UseMethod
,explains a bit of this, and points you to:
?methods
So you can write
methods(mean)
, and see which functions exist. For example mean.default, or
mean.data.frame, for which you can have a look at the code. An added
complication is that these functions are calling C-code by using
".Internal". This C-code can be found in cran, but as I don't know C,
I've never tried it out more than having a quick look. But it's there
if you want it.
Regards,
Gustaf Rydevik
--
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik
More information about the R-help
mailing list