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]]
you can see the different methods of mean by: methods(mean) Then you can type mean.default and you will see the complete code. Bart Alphonse Monkamg 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. > >-- View this message in context: http://www.nabble.com/function-in-R-tp19777553p19777674.html Sent from the R help mailing list archive at Nabble.com.
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
On Thu, Oct 2, 2008 at 6:34 AM, 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,Have a look at Uwe Ligges' "R Help Desk: Accessing the Sources" in http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf Hadley -- http://had.co.nz/