[R] inverse lexicographical ordering

Evgenia evgts at aueb.gr
Fri Feb 19 18:09:36 CET 2010


Dear users,

I have a matrix b as 

     [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    1    1
[3,]    0    1    0    1
[4,]    0    1    1    2
[5,]    1    0    0    1
[6,]    1    0    1    2
[7,]    1    1    0    2
[8,]    1    1    1    3


with last column the rowSums(b)
I want for each value of last column of b separately (b:0,1,2,3,  to sort
the above table  by reverse lexicographical order.
For the above table the result should be

1  0  0  0
2  1  0  0
3  0  1  0
4  0  0  1
5  1  1  0
6  1  0  1
7  0  1  1
8  1  1  1

Could anyone help me with this?
Thanks alot

Evgenia

-- 
View this message in context: http://n4.nabble.com/inverse-lexicographical-ordering-tp1561930p1561930.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list