[R] package survey

Martin Maechler maechler at stat.math.ethz.ch
Mon Dec 20 19:35:21 CET 2010

>>>>> "JS" == Joel Schwartz <joel at joelschwartz.com>
>>>>>     on Sat, 18 Dec 2010 19:09:24 -0800 writes:

    >> -----Original Message----- From: David Winsemius
    >> [mailto:dwinsemius at comcast.net] Sent: Saturday, December
    >> 18, 2010 5:54 PM To: Joel Schwartz Cc:
    >> r-help at r-project.org Subject: Re: [R] package survey
    >> On Dec 18, 2010, at 8:11 PM, Joel Schwartz wrote:
    >> >> and does anyone know if it is possible to find the
    >> codes for >> functions in survey package?
    >> >
    >> > Yes, you can find the code by doing the following:
    >> >
    >> > 1) Go to the CRAN R package list >
    >> (http://cran.r-project.org/web/packages/ > ), > scroll
    >> down to the "survey" package link and click on it.
    >> >
    >> > 2) Scroll down to the "Downloads" section and download
    >> the "package > source" > file. The "R" folder in this
    >> file contains the code for the functions > in the
    >> package.
    >> >
    >> > You can of course follow an analogous procedure to get
    >> the code for > other packages.
    >> >
    >> > There might be an easier or quicker way to do it from
    >> within R but ,if > there is, I haven't learned it yet.
    >> (I suspect Joel knows this.)
    >> If the package is loaded, you can just type the name of
    >> the function at the console.
    >> svyhist # produces about a half-page of code.
    JS> Yes, I should have suggested that option as well. It's
    JS> probably the quickest way if you just want the code for
    JS> one or a few functions. But if you want the code for
    JS> most or all functions in a package (including ones for
    JS> which you might not know the name off the top of your
    JS> head) is there some way of sending the code for all
    JS> functions in particular package to a ".r" file from the
    JS> command line with one or two lines of code?

Note that only the source package contains the real source code.
What you get when you print the object is the result of parsing
the original code and print()ing it.
In almost all cases, this will have lost all comments,
and will not format the same way the original authors have
formatted the original source ... 
which for good R programmers is typically better / easier to
read and understand than the parsed+deparsed version.

Martin Maechler, ETH Zurich (and R Core Team)

More information about the R-help mailing list