Hello,

Maybe something like the following. (Assuming your matrix is named 'mat')


mat[order(rowSums(mat)), ]


Hope this helps,

Rui Barradas


Em 23-05-2015 10:10, Ragia Ibrahim escreveu:
Dear group,
I have the following matrix

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

how to order it according to ones and zeros to be ordered as if it all ones 
orpartially finally all zeros, like  the following or similar


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


thanks in advance
Ragia





                                        
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to