[R] Combining Factors in model.matrix
paul.boutros@utoronto.ca
paul.boutros at utoronto.ca
Thu Jan 22 02:27:04 CET 2004
Hello,
I want to be able to create a design matrix with two factors. For instance, if
I have:
> t1 <- factor(c(1,1,2,2));
> t2 <- factor(c(1,2,1,2));
> design <- model.matrix(~ -1 + (t1+t2));
> design;
t11 t12 t22
1 1 0 0
2 1 0 1
3 0 1 0
4 0 1 1
But the design matrix I want is:
t1 t2
1 1 0
2 1 1
3 0 0
4 0 1
Actually, in general I'm struggling with the syntax for formulating a design
matrix I can write down on paper. Is there a reference for this beyond the R
documentation?
Thanks,
Paul
More information about the R-help
mailing list