[R] help: how to change the column name of data.frame
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Jul 19 12:49:35 CEST 2005
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 at 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
More information about the R-help