[R] sort a matrix on just one column
Petr Pikal
petr.pikal at precheza.cz
Wed Sep 10 17:11:18 CEST 2003
Hi
On 10 Sep 2003 at 10:50, Paul Green wrote:
> How can I sort(decreasing) a matrix on just the first column?
> For example, I can I get
>
> 8 2
> 7 5
> 4 1
>
> from
>
> 7 5
> 4 1
> 8 2
I am sure in help pages for sort() is a link to order()
> mat
x y
[1,] 7 5
[2,] 4 1
[3,] 8 2
> o<-order(mat[,1],decreasing=T)
> mat[o,]
x y
[1,] 8 2
[2,] 7 5
[3,] 4 1
>
> Thanks
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
CheersPetr Pikal
petr.pikal at precheza.cz
More information about the R-help
mailing list