I have a dataframe as below. I want a fourth column which contains the column name of the max value in that row.
df <- data.frame(tony=c(5,6,9), chuck=c(1,2,7), sam=c(2,9,1))
For example, see the data below. For the first row, max value is for tony, therefore value in the 4th column is tony, and so on.