I have a dataframe in which there are multiple factor columns, each of which is coded with the response "1" or "2" for "Yes" or "No", respectively. Each column encodes a single level of a 5-level factor as follows:
I want to use dplyr to combine the columns into a single factor column, with priority for the highest level for each case/row, so for this df it would be:
I've tried using mutate and chained if_else statements in dplyr to create a new column but so far haven't been able to do it. Frustratingly this is something I can do easily in Excel with nested IF statements! Many thanks in advance for any help.