0 votes
1 view
in R Programming by (43.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 (92.8k 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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...