I have a table in R that looks like this:
ID | Var1 | Var2 | Var3
1 | 0.2 | 0.5 | 0.3
2 | 0.6 | 0.4 | 0.0
3 | 0.1 | 0.4 | 0.5
I want to know for each ID which Var has the highest value. Thus, the final table should look like this:
ID | Var1 | Var2 | Var3 | HighVar
1 | 0.2 | 0.5 | 0.3 | Var2
2 | 0.6 | 0.4 | 0.0 | Var1
3 | 0.1 | 0.4 | 0.5 | Var3
How do I achieve this in R?