[R] Design matrix labels

John Logsdon j.logsdon at lancaster.ac.uk
Mon Jan 25 23:08:09 CET 1999


If I have two factors A and B with levels '1','2','3' and '1','4','6','8'
recpectively (note the gaps in the second one).  As factors, the levels
are named as above while of course the internal codes are (1,2,3) and
(1,2,3,4) respectively.

I want to make a design matrix of these as one would in a linear model
except I can't use lm or glm since the error distribution is not
tractable.  So I generate an overall factor as 10*A+B (for example) then
the internal codes and levels become 11,12,13,14,21,22,23,24,31,32,33,34.
I don't mind the internal codes, but is there a neater way of generating
the lm-type of factor levels a A*B to give the levels
'11','14','16','18','21','24','26','28','31','34','36','38'?

Better still would be to assign proper labels to the levels and get
factors a 'A1.B1','A1.B2' etc., basically mimicking the standard notation. 

Is there a proper way to do this other than for-looping and pasting? I
don't really want to create a hand-mapping because it is not robust to
changes. 

\John

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list