Skip to content
Prev 273185 / 398506 Next

Sorting data in R according to the header of another table

Try this:

X = 1:5; names(X) = letters[sample(5)]
Y = matrix(1:25, 5); colnames(Y) = letters[1:5]

Y[ , names(X)]

Hope this helps,

Michael Weylandt
On Oct 3, 2011, at 6:20 AM, "Samir Benzerfa" <benzerfa at gmx.ch> wrote: