I would like to get the column name of the each row maximum. In the following simple example:
A <- c(1, 3, 2, 13, 54, 641)
B <- c(2, 1, 54, 22, 100, 3)
C <- c(1, 9, 36, 1, 104, 23)
df1 <- data.frame(A,B,C)
df1
A B C
1 1 2 1
2 3 1 9
3 2 54 36
4 13 22 1
5 54 100 104
6 641 3 23
I would like to create a column (maxValue
) and get the column name of the maximum row:
A B C maxValue
1 1 2 1 B
2 3 1 9 C
3 2 54 36 B
4 13 22 1 B
5 54 100 104 C
6 641 3 23 A
Any suggestions would be highly appreciated :)