Hi. I want to find the second and third high results in a dataframe. Explication:
In this data frame:
max_vot <- data.frame(
P1 = c(310L, 349L, 2831L, 99L, 161L, 1353L, 196L, 113L, 23L),
P2 = c(193L, 111L, 3126L, 56L, 155L, 1261L, 92L, 125L, 47L),
P3 = c(122L, 147L, 3566L, 54L, 70L, 1007L, 123L, 88L, 22L),
P4 = c(30L, 42L, 645L, 18L, 10L, 247L, 43L, 15L, 6L),
P5 = c(47L, 45L, 574L, 41L, 17L, 378L, 39L, 20L, 5L)
)
using
max_vote <- colnames(max_vot)[max.col(max_vot, ties.method = "first")]
I can get the column that have the more high value row:
[1] "P1" "P1" "P3" "P1" "P1" "P1" "P1" "P2" "P2"
Now I want to get the second most high value column in each row, in this example will be: P2, P3, P2, P2, P2, P2, P3, P2, P1, P1
And then the third best value.
But thies.method only allow “random”, “first”, “last” as arguments. Any idea on how to deal with this?