[R] Newbie question: histogram
Douglas Bates
bates at stat.wisc.edu
Thu Feb 5 02:13:31 CET 2004
John Fox <jfox at mcmaster.ca> writes:
> 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.
But with any version of R compiled with the readline library and with
the Windows GUI and with ESS for emacs you can use the arrow keys to
retrieve the last line typed then edit it. Repeating information from
earlier lines is not terribly difficult.
I use the
with(datafr, func(colname))
paradigm in live sessions for introductory classes and I don't find it
overly cumbersome.
More information about the R-help
mailing list