Re: [R] Help on indicator variables

2013-03-22 Thread Tasnuva Tabassum
Thanks all. you guys are really helpful. On Fri, Mar 22, 2013 at 2:48 PM, peter dalgaard wrote: > What Bill says, plus the fact that the default handling of logicals in > modelling is to convert them to factors and then use treatment contrasts, > which will effectively give you the right indica

Re: [R] Help on indicator variables

2013-03-22 Thread peter dalgaard
What Bill says, plus the fact that the default handling of logicals in modelling is to convert them to factors and then use treatment contrasts, which will effectively give you the right indicator variables automagically (This in contrast to SAS where you can confuse yourself by declaring a 0/1

Re: [R] Help on indicator variables

2013-03-21 Thread William Dunlap
I would use a logical variable, with values TRUE and FALSE, instead of a numeric indicator. E.g., I find the following easier to follow bL <- ABS==1 | DEFF==1 if (any(bL)) { do.this() } than bN <- ifelse(ABS == 1 | DEFF == 1, 1, 0) if (any(bN == 1)) { do.this() } The latter leaves

Re: [R] Help on indicator variables

2013-03-21 Thread Göran Broström
On 03/21/2013 02:08 PM, Jorge I Velez wrote: Try ifelse(ABS ==1 | DEFF == 1, 1, 0) or as.numeric(ABS | DEFF) (faster?) Göran HTH, Jorge.- On Fri, Mar 22, 2013 at 12:02 AM, Tasnuva Tabassum wrote: I have two indicator variables ABS and DEFF. I want to create another indicator variabl

Re: [R] Help on indicator variables

2013-03-21 Thread Jorge I Velez
Try ifelse(ABS ==1 | DEFF == 1, 1, 0) HTH, Jorge.- On Fri, Mar 22, 2013 at 12:02 AM, Tasnuva Tabassum wrote: > I have two indicator variables ABS and DEFF. I want to create another > indicator variable which will take value 1 if either ABS=1 or DEFF=1. > Otherwise, it will take value 0. How c