Skip to content
Prev 56163 / 63424 Next

formula(model.frame(..)) is misleading

I don't have a copy of SV4 (or SV3, where model.frame was introduced), but
S+ 8.3 (based on SV4) puts the class "model.frame" on model.frame()'s
return value but has no methods (in the default packages) for class
"model.frame".  Perhaps that is why R omitted the class.

However, S+ 8.3's (and problably S's) formula.data.frame did look for a
"terms" attribute of a data.frame before making up an additive formula
based on the column names of a data.frame:

Splus-8.3> formula.data.frame
function(object)
{
        if(length(tms <- attr(object, "terms")))
                return(formula(tms))
        n <- names(object)
        f <- paste(n[-1.], collapse = "+")
        f <- parse(text = paste(n[1.], f, sep = "~"))[[1.]]
        oldClass(f) <- "formula"
        f
}



Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Dec 21, 2018 at 8:16 AM Fox, John <jfox at mcmaster.ca> wrote: