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]]
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
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.