jeudi 30 juin 2016

Create new variable if 2 of the 4 conditions are true using R

Is there any way to create a new variable var5 = 1 if any 2 of the 4 conditions are TRUE

Input:

 id var1 var2 var3 var4
1   60   18  36.7  1000
2   30   23  45.6  4000
3   10   35  75.6  5000
4   50   35   53   3000

condition1: if var1<20 or var1>25
condition2: if var2>25
condition3: if var3>20 
condition4: if var4<1000 or var4>3000 

Aucun commentaire:

Enregistrer un commentaire