I have a data frame called 'Health_Difficulties' that looks like the one below. I would need to merge:
Health_Difficulties = data.frame(
X = c(2,2,1,2,2,1,2,2,2,2,2),
Y = c(2,1,2,1,2,1,2,2,2,1,2),
Z = c(2,2,2,1,2,2,2,1,2,2,1)
)
into a new column named W, in order to eliminate the 3 columns and only keep W. What I'm trying to accomplish with this merger is that if either X or Y or Z has a 1, it would record a 1 on the W column, else if neither of the three columns has a 1, it would record a 2.
I'm new in R and have checked out dplyr but so far no luck. Any help would be very appreciated!