Ujjwal Upadhyay
Ujjwal Upadhyay

Reputation: 11

R functions to get key based on value of vector

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

Answers (1)

DanY
DanY

Reputation: 6073

Are you looking for which.max()?

vec = c(1,4,6,100,2)
which.max(vec)
#> 4

Upvotes: 1

Related Questions