[R] how does one print code
murdoch at stats.uwo.ca
Thu Apr 8 23:38:57 CEST 2010
On 08/04/2010 5:16 PM, David.Epstein wrote:
> There is quite a long piece of code defining a certain function in one of the
> R packages.
> I think the code has a bug and I want to get the code into a file so that I
> can take a proper look, and possibly fix it.
> how does one do this? (I mean getting the code into a file, not fixing the
> bug.) I suppose I could copy and paste, but that's a bit error prone for
> various reasons. I want the same arrangement of code formatting as in the
> original---copy and paste often messes this up.
You can't get this unless the package was installed with
R_KEEP_PKG_SOURCE. What you see in the console is *not* the original,
it's a deparsed version of it.
To get the original, download the source to the package, and look in the
R subdirectory. If it's a base package, the package sources are online at
This is the development trunk; different released versions will be in
different subdirs below /R, e.g. 2.10.1 will be in
> I tried using as.character(functionname) but that wasn't at all appreciated.
> I tried searching the archives of this forum but couldn't figure out
> exactly what to search for (got too many hits). I also tried Google, but
> that was also no help.
More information about the R-help