[R] S data sets in R?

Douglas Bates bates at stat.wisc.edu
Tue May 19 23:14:41 CEST 2009


On Tue, May 19, 2009 at 2:01 PM, Michael Hannon <jm_hannon at yahoo.com> wrote:
>
> Greetings.  I'm trying to learn to program in R.  (I'm definitely NOT new to
> programming, just to R.)  A colleague suggested that I have a look at the
> book:
>
>    An Introduction to S and S-Plus
> by:
>    Phil Spector
>
> I've glanced at the book, and it does indeed seem to be the kind of thing I
> wanted, but in the Introduction to the book, the author says he'll be using
> several example data sets throughout the book, including:
>
>    1. auto.stats
>
>    2. saving.x
>
>    3. rain.nyc1
>
>    4. state.x77
>
> The author states:
>
>    These data sets should be available as part of the standard
>    S distribution, so you can simply refer to them as they are
>    used in the examples.
>
> Of course I want to use R, not S.  I have every "R-*" package installed on my
> Fedora linux system, but I can't find any of the data sets mentioned above.
> (The command "locate rain.nyc" produces no output, for instance.)

Not an unreasonable first guess but in R you need parentheses around
the arguments in function calls and you would need to quote the name
of the object.  Even when you do those things and guess at the
function name being find instead of locate you still won't get any
joy.

> find("rain.nyc")
character(0)

The state.x77 data set is part of the datasets package but the others
never seemed to make it from S to R.  If you want to find out what is
available you can try

ls.str("package:datasets")

and stare at the output for a while until it begins to make sense.  In
general, an experienced programmer can learn a lot about the structure
of an object in R by applying Martin Maechler's str function to it.
The ls.str function is the equivalent of asking for a listing of the
objects in a namespace and applying str to each of those names.

Two recent books that I would recommend for learning R are Robert
Gentleman's "R Programming for Bioinformatics" and John Chambers
"Software for Data Analysis".  Robert (one of the two "R"'s who
started the R Project) gives you a broad overview of tools available
and considerable detail on the important parts.  John, the designer
and implementor of the S language the preceded R, describes how to
think about the programming task in R.  Both are worth reading.

> It's entirely possible that these data sets are installed, but I just don't
> know enough about R to determine that.
>
> Hence, I need to help to find out if the data sets are installed, or if they CAN
> be installed, etc.
>
> If you can steer me in the right direction, please do so.
>
> Thanks.
>
> -- Mike
>
> ______________________________________________
> 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.
>




More information about the R-help mailing list