Skip to content
Prev 38881 / 63421 Next

formula(model.frame(y~.^2, data=d)) does not return formula from terms attribute of the model.frame

On Thu, 6 Jan 2011, William Dunlap wrote:

            
But that has the advantage that you almost certainly have a model 
frame and hence that is what you intend.  With 6-6 (or 20-20 in 
Imperial units) hindsight it would have been better to give model 
frames a class inheriting from "data frame", but it seems that the 
presence of attr(, "terms") is the most common test.
Unfortunately, that is rather hard to tell!
I looked (not hard, but without success) for examples of calling 
formula() on a data frame.  I did see that model.frame.default() calls 
as.formula() on a data frame, but only after checking for the absence 
of a "terms" attribute.

Can you explain where it would help?  I think we need to see examples 
to see if a change in meaning would be clearly beneficial.  I can 
envisage cases in which 'x' was a data frame that just happened to 
have been constructed as a model frame and where the currently 
documented meaning was intended.