Re: [Rd] formula(CO2)

From: Ted Harding <ted.harding_at_nessie.mcc.ac.uk>
Date: Mon, 16 Jul 2007 15:14:40 +0100 (BST)


On 16-Jul-07 13:57:56, Ted Harding 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.
>
> So I tried:
>
> D<-data.frame(x=(1:10),y=(1:10))
>
> formula(D)
> x ~ y
>
> So, lo and behold, D has a formula!
>
> Or does it? Maybe if you give formula() a dataframe, it simply
> constructs one from the "columns".

Now that I think about it, I can see a use for this phenomenon:

  > formula(CO2)
  Plant ~ Type + Treatment + conc + uptake   > formula(CO2[,2:5])
  Type ~ Treatment + conc + uptake
  > formula(CO2[,3:5])
  Treatment ~ conc + uptake
  > formula(CO2[,4:5])
  conc ~ uptake
  > formula(CO2[,c(5,1,2,3,4)])
  uptake ~ Plant + Type + Treatment + conc

Could save a lot of typing!

Best wishes,
Ted.



E-Mail: (Ted Harding) <ted.harding_at_nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861
Date: 16-Jul-07                                       Time: 15:14:38
------------------------------ XFMail ------------------------------

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 16 Jul 2007 - 14:17:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 16 Jul 2007 - 14:36:46 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.