Re: [R] source of R functions {was ... aov ...}

From: Duncan Murdoch <>
Date: Fri 24 Jun 2005 - 03:13:30 EST

On 6/23/2005 12:57 PM, Martin Maechler wrote:

>>>>>> "RenE" == RenE J V Bertin <>
>>>>>>     on Thu, 23 Jun 2005 17:37:14 +0200 writes:

> RenE> Thanks to all the others who replied.
> BDR> and do note it is unset again a few lines later.
> BDR> (Listing a function inside R is not giving you the
> BDR> `source code'.)
> nor does RenE's fix(aov) {mentioned later in his post}.
> We have been on this topic many times: The source code is in
> *files*, publicly available from CRAN (and even with your web
> browser from where e.g. tags/R-2-1-1/
> contains the source of R 2.1.1).
> And this applies to CRAN (or Bioconductor) packages as well as
> the "base R" code: The real source is in files.
> Looking at the object {via "typing its name" or e.g. fix() or an
> "object browser"} basically (not quite!) provides the result of
> source() {+ save() and load() in some cases} of the original
> source files; and this should be about the same as what you'd
> get from print( parse(...) ) of the source text.
> What's the difference? At least these:
> 1a) All the comments inside functions are lost.
> 1b) all other comments between object {typically function} definitions,
> and the grouping {into files; sections inside files, ...}
> and logical sequence of the definitions is lost.
> 2) The author's formatting is lost.
> 3) only " ... " are used for strings (even when the original had '...')
> 4) numerical constants are shown in a uniform way, not as
> entered { .1 |-> 0.1 1e1 |-> 10 etc }
> where "1)" and "2)" can be important and I consider a drawback;
> 3 and 4 are less important and typically an advantage,
> and '2)' is an advantage for some people's R code because it
> makes it prettier. (! ;-)

Everything you say is correct, but one point might confuse some people:   it is possible to attach the source to a function definition, so that fix() will keep comments, etc. "options(keep.source=TRUE)" makes this happen, and that's the default setting for interactive use. The point is that the installed packages are normally built with this option set to FALSE, so the source is only in the files.

Duncan Murdoch mailing list PLEASE do read the posting guide! Received on Fri Jun 24 03:16:49 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:00 EST