[R] mapple
Phillip Heinrich
herd_dog @end|ng |rom cox@net
Wed Oct 2 04:32:04 CEST 2019
With the snippet of data below I’m trying to do an if/then type of thing:
row 1 – if all five variables equal 0 then code equals 1;
row 3 – if v1 = 1 and v2 = 1 then code = 5;
row 7 – if v1 = 0 and v2 = 1 and v3 = 2 then code = 10
There are 24 codes in the complete database.
v1 v2 v3 v4 v5 code
1 0 0 0 0 0 1
2 1 4 0 0 0 1
3 1 1 0 0 0 1
4 1 0 1 0 0 1
5 2 0 1 0 0 1
6 0 1 0 0 0 1
7 0 1 2 0 0 1
8 0 1 2 3 0 1
9 0 2 3 4 4 1
10 0 0 0 2 3 1 I understand that the mapply function can do things like this but I have been reading documentation and poking around with Google but am getting nowhere. Any advise whould be greatly appreciated.
[[alternative HTML version deleted]]
More information about the R-help
mailing list