Hi R users,
I would like to know how to sort a matrix according a different order of
colnames (or rownames) ,e.g.,
mx = matrix(rnorm(1:20),5,4)
colnames(mx) = letters[1:4]
rownames(mx) = letters[1:5]
mx
a b c d
a 0.02362598 -0.7033460 0.8106089
try:
mx[,new.col.names]
HTH.
On 2/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hi R users,
I would like to know how to sort a matrix according a different order of
colnames (or rownames) ,e.g.,
mx = matrix(rnorm(1:20),5,4)
colnames(mx) = letters[1:4]
rownames(mx) = letters[1:5]
mx
mx = matrix(rnorm(1:20),5,4)
colnames(mx) = letters[1:4]
rownames(mx) = letters[1:5]
mx
a b c d
a -0.6264538 -0.8204684 1.5117812 -0.04493361
b 0.1836433 0.4874291 0.3898432 -0.01619026
c -0.8356286 0.7383247 -0.6212406 0.94383621
d 1.5952808