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

Kevin Wright kw.statr at gmail.com
Fri May 18 16:45:07 CEST 2007

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:


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...)


K Wright

More information about the R-devel mailing list