This question already has an answer here:
Given the following data :
df <- data.frame(
a = c(1,2,3,5),
b = c(7,9,52,4),
c = c(53, 11,22,1),
d = c("something","string","another", "here")
)
Which looks as :
a b c d
1 1 7 53 something
2 2 9 11 string
3 3 52 22 another
4 5 4 1 here
I would like to create column "max" using dplyr, where max
is the column of
the largest row value.
So for the above I would have
a b c d max
1 1 7 53 something c
2 2 9 11 string c
3 3 52 22 another b
8 5 4 1 here a