Re: [R] help: how to change the column name of data.frame

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 19 Jul 2005 - 20:49:35 EST

On Tue, 19 Jul 2005, wu sz wrote:

> Thanks a lot! But DF[c(4,6)] <- DF[c(6,4)] seems to just exchange
> the data, not the names. If exchanging the columns(both data and
> names) needs two steps?
>
> DF[c(4,6)] <- DF[c(6,4)]
> names(DF)[c(4,6)] <- names(DF)[c(6,4)]

Yes, it does. You did however say in your first message that you wanted to exchange the data, despite the subject line.

As I asked before *PLEASE* do try to be precise in what you want to do.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Jul 19 20:53:07 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:46 EST