[R] Re order matrix columns

mentor_ mentor_ at gmx.net
Mon Nov 10 22:59:09 CET 2008


Hi,

found a quite simple solution:

test
     a  b  c  d  e
[1,] 1 11 21 31 41
[2,] 2 12 22 32 42
[3,] 3 13 23 33 43
[4,] 4 14 24 34 44
[5,] 5 15 25 35 45

list <- c("b", "c", "a", "e", "d")

test[,list]




mentor_ wrote:
> 
> Hi,
> 
> I have found the following thread to reorder a data.frame.
> I would like to do same regarding a matrix:
> 
> https://stat.ethz.ch/pipermail/r-help/2008-February/154138.html
> 
> I achieved this with a for loop and cbind but I think using 'is.element'
> is much more
> appropriate. Can anyone help?
> 
> Cheers
> 

-- 
View this message in context: http://www.nabble.com/Reorder-matrix-columns-tp20428678p20428869.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list