Re: [R] sort adjacency matrix

2015-04-06 Thread David Winsemius
On Apr 6, 2015, at 11:15 AM, Bert Gunter wrote: > Not quite, David. > > If I understand the OP's query, he wants the ties to be broken by the > "lexicographic" order (with apologies if I have misused this term) of > the 1's within the rows. Makes things a bit more interesting. This should corre

Re: [R] sort adjacency matrix

2015-04-06 Thread Rui Barradas
Hello, You should have used ?dput to post your data example. Since you haven't, I've made up one. set.seed(4795) mat <- matrix(sample(0:1, 24, replace = TRUE), nrow = 6) mat inx <- order(rowSums(mat), decreasing = TRUE) mat[inx, ] Hope this helps, Rui Barradas Em 06-04-2015 18:18, Ragia Ibr

Re: [R] sort adjacency matrix

2015-04-06 Thread Bert Gunter
Not quite, David. If I understand the OP's query, he wants the ties to be broken by the "lexicographic" order (with apologies if I have misused this term) of the 1's within the rows. Makes things a bit more interesting. Have at it! Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (6

Re: [R] sort adjacency matrix

2015-04-06 Thread David L Carlson
The answer depends on what kind of matrix/data frame you have. That is why we encourage people to use dput() to create a copy of the sample data in their email. Some combination of order() function the rowSums() function will probably get you what you want. For example, dat[order(rowSums(dat=="