From kw.statr at gmail.com  Fri May 18 16:45:07 2007
From: kw.statr at gmail.com (Kevin Wright)
Date: Fri, 18 May 2007 09:45:07 -0500
Subject: [Rd] Is formula(data.frame) documented?
Message-ID: <c968588d0705180745x654e1b28y12ee9ca5c129f55@mail.gmail.com>

The Examples section of 'unstack' includes:

formula(PlantGrowth)         # check the default formula

I wanted to add a formula to my own data.frame (for unstacking), so I
start looking:
?formula  # Nothing here about adding a formula to data
attr(PlantGrowth, "formula") # Nothing here--c.f. groupedData objects
dput(PlantGrowth) # Hmm, no formula here either
?formula.data.frame # Aliased to formula.  Growing more frustrated.

After more experimentation, I guessed that 'formula.data.frame' is
using the first column as the response and other columns as model
terms.  Eventually I had the idea to look in S-Plus:

?formula.data.frame

This is a method for the function formula() for objects inheriting
from class data.frame. If object is a model frame, the formula for the
model frame is returned, otherwise a formula is deduced from the names
of object. The first name is taken to be the response, and all the
remaining names are pasted together additively.

Ah.  Simple, lucid.

Two notes:

1. Would it be possible to add documentation for formula.data.frame?
(I can create a .Rd file--just ask).

2. General comment to the R community: As a user, I sometimes find
that it would be much clearer to have separate help files with links
in the 'See Also' section rather than using 'aliased' help for
multiple functions in a single file.  (I readily admit that separate
help files are more work...)

Thanks,

K Wright



[Rd] Is formula(data.frame) documented?
Kevin Wright