Subject: model.matrix() (PR#285)
Date: Wed 22 Sep 1999 - 20:32:12 EST
I was alarmed to discover that model.matrix.default() can permute columns
with respect to the formula. This seems to happen with user-defined
components of the formula. Thus
X <- matrix(1:4, 1, 4, dimnames = list(NULL, LETTERS[1:4]))
Q <- function(x) x^2 # because model.matrix() does not like, eg, A:A
model.matrix(~ -1 + A + A:B + Q(C), data.frame(X))
has columns ordered A, Q(C), and A.B, not A, A.B, Q(C), as you might
expect (and I certainly expected!). This appears to happen .Internal-ly.
While on the subject, would it be reasonable to standardise the names of
interaction terms to be A:B not A.B, to match the terms in the formula.
Jonathan Rougier Science Laboratories
Department of Mathematical Sciences South Road
University of Durham Durham DH1 3LE
"[B]egin upon the precept ... that the things we see are to be
weighed in the scale with what we know" (Meredith, 1879, The Egoist)
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: email@example.com
This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:08 EST