I have the following problem mydata <- data.frame(a=1:3) form <- ~ (a>1) - 1 model.matrix(form,mydata)
a > 1FALSE a > 1TRUE 1 1 0 2 0 1 3 0 1 ... However model.matrix(update(terms(form)[1],~.-1),mydata) (Intercept) a > 1 - 1TRUE 1 1 1 2 1 1 3 1 1 ... Taking terms(form)[1] extracts the formula with only the first term, but the parentheses are thrown away, and after the update, I get a different formula. Is that supposed to be so? Thanks, Niels -- Niels Richard Hansen Web: www.math.ku.dk/~richard Associate Professor Email: niels.r.han...@math.ku.dk Department of Mathematical Sciences nielsrichardhan...@gmail.com University of Copenhagen Skype: nielsrichardhansen.dk Universitetsparken 5 Phone: +45 353 20783 (office) 2100 Copenhagen Ø +45 2859 0765 (mobile) Denmark ______________________________________________ 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.