[R] Really a newbe Q about data.frames

Prof Brian D Ripley ripley at stats.ox.ac.uk
Mon Feb 4 09:15:17 CET 2002


On Mon, 4 Feb 2002, Fredrik Karlsson wrote:

> Hi all (again)
>
> Sorry to bother you with this lame question, but since I have not been
> able to find the answer in the manuals..
> How do I change the name of a variable in a data.frame??
> (Without copying hte entire fram to another one of course..)

via names:

DF <- data.frame(a=1, b=2)
names(DF)[2] <- "bb"
DF
  a bb
1 1  2

(Actually, that does make a copy internally).

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list