On 28/07/2009, at 9:45 AM, Mark Na wrote:

Hi R-helpers,

I have written this line of code:

data<-cbind(data[,1],data[,2:6],data[,18],data[,7:17])

to reorder the columns of my dataframe, but I'm losing the column names of
my 1st and 18th columns (they are now named data[,1] and data[,18]
respectively).

Can I use cbind to do this (without losing my column names) or is there
another way?

Just do

        data <- data[,c(1:6,18,7:17)]

        cheers,

                Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to