Back
I just want to determine the indices of elements of an unsorted vector in an order and let say the order is from lowest to highest.
Example:
vec <- c(14, 50, 10, 41, 9)return_indices(vec)5 3 1 4 2
vec <- c(14, 50, 10, 41, 9)
return_indices(vec)
5 3 1 4 2
I think there is an easy way to achieve this...
In R programming you can simply achieve your goal with the help of sort and match():
match(sort(vec), vec)#[1] 5 3 1 4 2
match(sort(vec), vec)
#[1] 5 3 1 4 2
31k questions
32.8k answers
501 comments
693 users