Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in R Programming by (50.2k points)

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 

I think there is an easy way to achieve this... 

1 Answer

0 votes
by (108k points)

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

Browse Categories

...