Message-ID: <48DC16A7.4060804@gmail.com>
Date: 2008-09-25T22:54:31Z
From: Mark
Subject: How to order some of my columns (not rows) alphabetically
Hello,
I have a dataframe with 9 columns, and I would like to sort (order) the
right-most eight of them alphabetiaclly, i.e.:
ID1 ID2 F G A B C E D
would become
ID1 ID2 A B C D E F G
Right now, I'm using this code:
attach(data)
data<-data.frame(ID1,ID2,data[,sort(colnames(data)[3:9])])
detach(data)
but that's not very elegant. Ideally I could specify which columns to
sort and which to leave "as is" (but my attempts to do so have failed).
Thank you,
Mark