[R] Re-Post: Combining Factors in model.matrix
paul.boutros@utoronto.ca
paul.boutros at utoronto.ca
Sat Jan 24 08:31:19 CET 2004
Hello,
I didn't get any response on this before, leading me to believe I've missed
something fundamental. Can anybody guide me in the correct direction for more
help on this?
Paul
=================================================
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