I have some data that looks like this:
there are four columns with values, I want to find out for each row, out of three of those columns, which one has the largest value of the three.... the final result that I want is an additional column that shows the character name of the column with the largest value for each row
so a new column that would look like
ID type n_urban n_rural n_comp_rural n_counties
rural
mixed
rural
urban
Is it best to use a for loop? or should I just do this with ifelse statements?
Thanks!
structure(list(economic_area_id = c(57001, 57002, 57003, 57004,
57005, 57006, 57007, 57008, 57009, 57010), n_urban = c(2, 5,
8, 7, 4, 0, 15, 6, 4, 2), n_rural = c(2, 2, 13, 6, 2, 8, 3, 6,
6, 10), n_comp_rural = c(9, 5, 6, 1, 0, 3, 9, 16, 1, 2), n_counties = c(13,
12, 27, 14, 6, 11, 27, 28, 11, 14)), class = c("tbl_df", "tbl",
"data.frame"), row.names = c(NA, -10L))