[R] order of values in vector
Berwin A Turlach
statba at nus.edu.sg
Mon Mar 19 10:20:23 CET 2007
G'day Tord,
On Mon, 19 Mar 2007 10:05:47 +0100
Tord Snäll <tord.snall at nvb.slu.se> wrote:
> but I was hoping to get this:
> x
> [1,] 2 20
> [2,] 3 30
> [3,] 5 50
> [4,] 4 40
> [5,] 6 60
> [6,] 1 10
You did try rank(), didn't you?
> x= c(20,30,50,40,60,10)
> cbind(rank(x), x)
x
[1,] 2 20
[2,] 3 30
[3,] 5 50
[4,] 4 40
[5,] 6 60
[6,] 1 10
HTH.
Cheers,
Berwin
More information about the R-help
mailing list