From m@echler @ending from @t@t@m@th@ethz@ch  Sun Dec 23 16:52:25 2018
From: m@echler @ending from @t@t@m@th@ethz@ch (Martin Maechler)
Date: Sun, 23 Dec 2018 16:52:25 +0100
Subject: [Rd] formula(model.frame(..)) is misleading
In-Reply-To: <CAF8bMcZJ6VGFzTDQfstkw8EvfBo76fWrB2mPW7Z_=bhgx04H1Q@mail.gmail.com>
References: <CAF8bMcaSrPfpdJMOeDg0ptJBLJrZvOJiEy7Bdkf3-oZZwNYnuw@mail.gmail.com>
 <27876_1545378678_wBL7pHYd012851_23580.39786.529658.257284@stat.math.ethz.ch>
 <3A66F355-79A3-4E1F-BADF-9773BBCEA02E@mcmaster.ca>
 <CAF8bMcZJ6VGFzTDQfstkw8EvfBo76fWrB2mPW7Z_=bhgx04H1Q@mail.gmail.com>
Message-ID: <23583.44857.565786.577671@stat.math.ethz.ch>

>>>>> William Dunlap via R-devel 
>>>>>     on Fri, 21 Dec 2018 13:34:16 -0800 writes:

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

aahh.. that's very relevant,  thank you very much, Bill, for digging!

    > 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
    > }

There's quite a bit of code looking for  attr(*, "terms")
anyway in our code base, so indeed, this would be internally
consistent with the existing code base and hence probably the
best way to solve the original problem. 

I'll look into committing this to R-devel soonish.

Martin


    > Bill Dunlap
    > TIBCO Software
    > wdunlap tibco.com



[Rd] formula(model.frame(..)) is misleading
Martin Maechler