[R] Help on indicator variables

Göran Broström gb at stat.umu.se
Thu Mar 21 15:05:25 CET 2013


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 <t.tasnuva at gmail.com>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 can I make that?
>>
>>          [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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.
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list