[Rd] formula(CO2)
Gabor Grothendieck
ggrothendieck at gmail.com
Mon Jul 16 16:30:48 CEST 2007
Good point.
It seems that the "groupedData" methods are all in the nlme package yet
CO2 is in datasets. CO2 should probably be moved to nlme.
Of course one still wonders whether the way formula currently works on
data frames is really intended and desirable. Ted's point is well taken
but I think formula.data.frame could still have the current default
yet be user overridable via the formula attribute.
On 7/16/07, Gavin Simpson <gavin.simpson at ucl.ac.uk> wrote:
> On Mon, 2007-07-16 at 14:57 +0100, ted.harding at nessie.mcc.ac.uk wrote:
> > On 16-Jul-07 13:28:50, Gabor Grothendieck wrote:
> > > The formula attribute of the builtin CO2 dataset seems a bit strange:
> > >
> > >> formula(CO2)
> > > Plant ~ Type + Treatment + conc + uptake
> > >
> > > What is one supposed to do with that? Certainly its not suitable
> > > for input to lm and none of the examples in ?CO2 use the above.
> >
> > I think one is supposed to ignore it! (Or maybe be inspired to
> > write a mail to the list ... ).
> >
> > I couldn't find anything that looked like the above formula from
> > str(CO2). But I did spot that the order of terms in the formula:
> > Plant, Type, treatment, conc, uptake, is the same as the order
> > of the "columns" in the dataframe.
>
> CO2 is a groupedData object not a data.frame per se.
>
> > class(CO2)
> [1] "nfnGroupedData" "nfGroupedData" "groupedData" "data.frame"
>
> What Gabor saw was the result of formula.data.frame being applied to
> CO2, which, as you surmise Ted, is being produced from the columns of
> CO2.
>
> > formula(CO2)
> Plant ~ Type + Treatment + conc + uptake
> > stats:::formula.data.frame(CO2)
> Plant ~ Type + Treatment + conc + uptake
>
> But if we load nlme, we see that now (via a groupedData method for
> formula) a more useful formula is displayed.
>
> > require(nlme)
> Loading required package: nlme
> [1] TRUE
> > formula(CO2)
> uptake ~ conc | Plant
>
> as this can then be directly used in lme
>
> > lme(CO2)
> Linear mixed-effects model fit by REML
> Data: CO2
> Log-restricted-likelihood: -283.1447
> Fixed: uptake ~ conc
> (Intercept) conc
> 19.50028981 0.01773059
> <snip />
>
> But like Gabor, I'm struggling to see where this [formula(data.frame)]
> might be used (useful)?
>
> G
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> Gavin Simpson [t] +44 (0)20 7679 0522
> ECRC, UCL Geography, [f] +44 (0)20 7679 0565
> Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
> Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
> UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>
>
More information about the R-devel
mailing list