[R] if else with 4 conditions problem
smart hendsome
putr@_@utumn86 @ending from y@hoo@com
Sun May 27 16:13:23 CEST 2018
Hi everyone,
I have two columns:
A B
1 1 1 0
0 1
0 0
I have 4 categories which are:
1) if A = 1 and B =1 then A1 = 1, else A2 = 0, A3 = 0, A4 = 0
2) if A = 1 and B =0 then A1 = 0, else A2 =1, A3 = 0, A4 = 0
3) if A = 0 and B = 1 then A1 = 0, else A2 = 0, A3 = 1, A4 = 0
4) if A = 0 and B =0 then A1 = 0, else A2 = 0, A3 = 0, A4 = 1
I want the data become like below:
A B A1 A2 A3 A4
1 1 1 0 0 0 1 0 0 1 0 0
0 1 0 0 1 0
0 0 0 0 0 1
Anyone can help me? Many Thanks.
Regards,
Zuhri
| | Virus-free. www.avast.com |
[[alternative HTML version deleted]]
More information about the R-help
mailing list