Reputation: 11
Is there any R function to find key of max value of an vector?
We have similar function as list_name.index(max(list_name))
in python.
Upvotes: 1
Views: 17
Reputation: 6073
Are you looking for which.max()
?
vec = c(1,4,6,100,2)
which.max(vec)
#> 4
Upvotes: 1