[R] Newbie question: histogram
John Fox
jfox at mcmaster.ca
Wed Feb 4 20:25:38 CET 2004
Dear Martin,
At 06:07 PM 2/4/2004 +0100, Martin Maechler wrote:
> >>>>> "JohnF" == John Fox <jfox at mcmaster.ca>
> >>>>> on Wed, 04 Feb 2004 09:20:43 -0500 writes:
>
> JohnF> Dear Philippe, I suppose that you want a histogram
> JohnF> for snow.cover and not for year. There are several
> JohnF> ways to proceed; two are
>
> JohnF> hist(mydata$snow.cover)
>
> JohnF> and
>
> JF> attach(mydata)
> JF> hist(snow.cover)
>
>Actually, attaching data frames is a bit discouraged these days.
>The modern R way for this (and more complicated situations) is
>
> with(mydata, hist(snow.cover) )
>
Although I'm aware of (some of) the problems and possibly confusing
situations that can arise from attaching a data frame, I believe that,
especially for novice users, there's an advantage in doing so. In
particular, although using with() is perhaps less ambiguous, it is
necessary to repeat it for each command.
Regards,
John
> JohnF> More generally, it's a good idea to read the
> JohnF> introductory manual that comes with R (or a book that
> JohnF> introduces R). See, in particular, the section on
> JohnF> lists and data frames in the Introduction to R.
>
>definitely!
>
>Martin
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
More information about the R-help
mailing list