>>>>> 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 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel