tan
tan

Reputation: 1569

Find indices of multiple maximums in a vector

which.max Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector. If the vector has multiple max, how can I retrieve all of them?

Upvotes: 20

Views: 18780

Answers (1)

mathematical.coffee
mathematical.coffee

Reputation: 56945

You could do which( myVector == max(myVector) ), which is basically what which.max is (except that which.max stops at the first occurence and is implemented a bit more efficiently).

Upvotes: 47

Related Questions