The ordering index vector is a vector that contains indices of another vector. It’s basically the other vector, but ordered (decreasing or increasing). Instead of having the values it has the indices :) I spent close to an hour to find this line :) And here it is. In all its glory :)

sort.int(VECTOR, index.return=TRUE)

The result of this command is a bit strange (for me). It returns an object that contains the ordered vector and the ordered index vector in a list. Long story short, I can’t access them like I would want to. So the command I ended up using is a bit more complex:

unlist(as.matrix(sort.int(VECTOR, index.return=TRUE))[2])

Notice that I coerce the resulting list into a matrix. This results in a matrix containing two elements: [1]->ordered vector and [2]-> ordered index vector. Therefore I chose the second element in the returned list and unlisted it into a vector. This is what I wanted as I can index a vector :)

### Like this:

Like Loading...

*Related*

## About joelgranados

I'm fascinated with how technology and science impact our reality and am drawn to leverage them in order to increase the potential of human activity.

sort.int(VECTOR, index.return=TRUE)$ix is the way where to go.

Wouldn’t using order(VECTOR) do the trick? it returns a vector and is easy to use :)

Hey W.F.

This was such a long time ago that I forgot what I used it for. I think order(VECTOR) would have also served my purposes, and its simpler. Thx for the feedback :)