search for: alpahbetical

Displaying 1 result from an estimated 1 matches for "alpahbetical".

2008 May 19
2
Sort matrix with duplicate row names alphabetically by rowname
...licates of each rowname. (4 a's, 4 b's, 4 c's in no particular order) Like this: # c 32 a 1 b 4 c 87 c 34 b 54 a 23 a 12 b 9 a 3 b 87 c 43 There are a couple of more columns but I'm using the above as an example I need to sort it so that the same rownames appear together in alpahbetical order. Like this: # a 1 a 23 a 12 a 3 b 4 b 54 b 9 b 87 c 87 c 34 c 43 c 32 The code I came up with is something like this: mat <- mat[sort(rownames(mat)), ] This doesn't work though, it returns the same value for each row each time, something like this: # a 1 a 1 a 1 a 1 b 4 b 4 b...