Skip to content
Prev 349762 / 398513 Next

sort adjacency matrix

On Apr 6, 2015, at 11:15 AM, Bert Gunter wrote:

            
This should correct the problem:
+           apply(M, 1, paste0, collapse=".") ,
+           decreasing=TRUE), ]
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    0    1    1    1    0    0    0    0    0     0
 [2,]    0    0    0    1    1    0    1    0    0     0
 [3,]    1    0    0    0    0    0    0    0    0     0
 [4,]    1    0    0    0    0    0    0    0    0     0
 [5,]    1    0    0    0    0    0    0    0    0     0
 [6,]    0    1    0    0    0    0    0    0    0     0
 [7,]    0    1    0    0    0    0    0    0    0     0
 [8,]    0    0    0    0    1    0    0    0    0     0
 [9,]    0    0    0    0    1    0    0    0    0     0
[10,]    0    0    0    0    0    0    0    0    0     0

The original matrix was sparse and I get this error message when attempting to use 'order' in the i-argument to the `[` method for dgCMatrix: 

Error in m[order(rowSums(m == "1"), apply(m, 1, paste0, collapse = "."),  : 
  error in evaluating the argument 'i' in selecting a method for function '[': Error: not-yet-implemented method for ==(<dgCMatrix>, <character>).
 ->>  Ask the package authors to implement the missing feature.


HTH;