For the following data set
> data
x1 x2 x3
1 1 0 0
2 0 1 0
3 0 0 1
4 0 0 1
5 1 0 0
6 0 1 0
7 1 0 0
8 0 1 0
9 0 0 1
10 1 0 0
I would like to create new variable z such that it takes 1 if x1=1, 2 if x2=1 and 3 if x3=1, z will look like z=c(1,2,3,3,1,2,1,2,3,1).
Any help is appreciated