From J.C.Rougier@durham.ac.uk  Wed Sep 22 11:32:12 1999
From: J.C.Rougier@durham.ac.uk (J.C.Rougier@durham.ac.uk)
Date: Wed, 22 Sep 1999 12:32:12 +0200 (MET DST)
Subject: model.matrix() (PR#285)
Message-ID: <199909221032.MAA17796@pubhealth.ku.dk>

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.

Cheers, Jonathan.

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: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


model.matrix() (PR#285)
J.C.Rougier@durham.ac.uk