Hi Folks, I'm a bit puzzled by the following (example): N<-factor(sample(c(1,2,3),1000,replace=TRUE)) unique(N) # [1] 3 2 1 # Levels: 1 2 3
So far so good. Now: contrasts(N)<-contr.treatment(3, base=1, contrasts=FALSE) contrasts(N) # 1 2 # 1 1 0 # 2 0 1 # 3 0 0 whereas: contr.treatment(3, base=1, contrasts=FALSE) # 1 2 3 # 1 1 0 0 # 2 0 1 0 # 3 0 0 1 contr.treatment(3, base=1, contrasts=TRUE) # 2 3 # 1 0 0 # 2 1 0 # 3 0 1 I can follow the last two fine -- they are what is implied by the code for contr.treatment(). Likewise: contrasts(factor(Nlevs <-c(1,2,3))) # 2 3 # 1 0 0 # 2 1 0 # 3 0 1 But why the different result when applied to N? With thanks, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 20-May-08 Time: 01:12:30 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.