Well, having decided to get to know some of the basic functions in R I’ve stumbled upon the sort.list() function. I get the pretty straight forward sort() function, but don’t get the idea of the sort.list(). I’ve read that it should be a permutation function rearranging the content of my vector (in some way).
Having the vector;
x <- c(5.0, 3.0, 2.0, 2.2, 0.0, 5.0, 3.0, 2.0, 2.2)
Running sort.list(x) outputs
[1] 5 3 8 4 9 2 7 1 6
Where did that come from? Can someone give me a hint please? And what’s the use of this permutation anyway?
Thanks.
sort.list, as it says at?sort.list, is the same asorder, only instead of accepting multiple arguments via..., it accepts only one atomic vector as an argument.Presumably, then, it could be intended as a “faster” or “simpler” version of
order.What good is it? Consider this:
Just like
orderit returns a permutation that when used to index the original vector sorts it.But I also think the name is confusing.