Trevor's problem is reproducible on R 1.8.1 (which is what he was using) on both Linux RHEL 3.0 and Solaris and R 1.8.0 on Windows.
----- Original Message ----- From: "Trevor Hastie" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 24, 2004 3:12 PM Subject: [R] problem with model.matrix > This works: > > > > model.matrix(~I(pos>3),data=data.frame(pos=c(1:5))) > (Intercept) I(pos > 3)TRUE > 1 1 0 > 2 1 0 > 3 1 0 > 4 1 1 > 5 1 1 > attr(,"assign") > [1] 0 1 > attr(,"contrasts") > attr(,"contrasts")$"I(pos > 3)" > [1] "contr.treatment" > > > This does not: > > > model.matrix(~I(pos>3),data=data.frame(pos=c(1:2))) > Error in "contrasts<-"(`*tmp*`, value = "contr.treatment") : > contrasts can be applied only to factors with 2 or more levels > > > -------------------------------------------------------------------- > Trevor Hastie [EMAIL PROTECTED] > Professor, Department of Statistics, Stanford University > Phone: (650) 725-2231 (Statistics) Fax: (650) 725-8977 > (650) 498-5233 (Biostatistics) Fax: (650) 725-6951 > URL: http://www-stat.stanford.edu/~hastie > address: room 104, Department of Statistics, Sequoia Hall > 390 Serra Mall, Stanford University, CA 94305-4065 > -------------------------------------------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
