max - Choosing highest number in vector and knowing its position in R -


i have vector in r:

y=c(-29.900900, 5.728916, 35.234331,  11.854811,  61.309519,  50.432798, -27.654741,  21.413622, -10.805339, -37.504199) 

i select highest number using example max(y).

then gives me 61.309519.

but in addition know position i.e. 5th element in vector.

is there way this? i'm ok using other data formats eg. matrix or data.frame

which.max()  

function return index of first maximum element. might important when have more 1 maximum in vector.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -