[R] Reordering inputs
Steven Kennedy
stevenkennedy2263 at gmail.com
Thu May 12 00:10:27 CEST 2011
You can order each matrix by any column you choose like:
a<-matrix(rnorm(20),ncol=2)
> a[order(a[,1]),] #orders by column 1
[,1] [,2]
[1,] -1.86523489 -1.6920270
[2,] -0.94488744 0.2815087
[3,] 0.02380494 0.2491136
[4,] 0.37295795 0.8156993
[5,] 0.55533366 -0.7053233
[6,] 0.79799294 -0.8224082
[7,] 0.80497452 0.4260842
[8,] 1.12438976 -0.1567863
[9,] 1.29213037 -1.6783762
[10,] 1.33496542 0.7807943
More information about the R-help
mailing list