Re: [R] Problem with terms of the form (a >1) and subsetting of a terms object

2010-08-26 Thread peter dalgaard
On Aug 26, 2010, at 10:35 AM, Niels Richard Hansen wrote: > > > On 26/08/10 09.30, Dimitris Rizopoulos wrote: >> I think you need an I(), i.e., >> >> form <- ~ I(a > 1) - 1 > > Yes, it solves the concrete problem, but does not really answer > the question. Let me rephrase. Should the use of t

Re: [R] Problem with terms of the form (a >1) and subsetting of a terms object

2010-08-26 Thread Niels Richard Hansen
On 26/08/10 09.30, Dimitris Rizopoulos wrote: I think you need an I(), i.e., form <- ~ I(a > 1) - 1 Yes, it solves the concrete problem, but does not really answer the question. Let me rephrase. Should the use of terms like (a>1) be discouraged in R and replaced by I(a>1) systematically, or

Re: [R] Problem with terms of the form (a >1) and subsetting of a terms object

2010-08-26 Thread Dimitris Rizopoulos
I think you need an I(), i.e., form <- ~ I(a > 1) - 1 I hope it helps. Best, Dimitris On 8/26/2010 9:17 AM, Niels Richard Hansen wrote: 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 ... Howeve

[R] Problem with terms of the form (a >1) and subsetting of a terms object

2010-08-26 Thread Niels Richard Hansen
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