[R] renaming column names
b.chain at ucl.ac.uk
Sun May 31 20:54:47 CEST 2009
Problem solved ! Remarkably, I saw your previous post about stringsasFactors
<- false and that was the root of the problem. I was trying to rename the
columns according to contents of one of the rows of the data frame, which
were being interpreted as factors (which I hadn't realised) and that's why
the assignment as new column names didn't work !
Thanks for your help, albeit inadvertent !
Division of Infection and Immunity
UCL, 46 Cleveland St.
London W1T 4JF
Fax 00 44 20 7679 9301
From: David Winsemius [mailto:dwinsemius at comcast.net]
Sent: 31 May 2009 17:11
To: Benny Chain
Cc: r-help at r-project.org
Subject: Re: [R] renaming column names
Cannot reproduce with a toy example:
> data <- data.frame(a=1:3, b=4:6, c=6:8)
> colnames(data) <- c("d","e","f")
 "d" "e" "f"
Perhaps you need to produce more detail. Surely offering the results
of dput(a) would not tax the limits of the R-mail server.
On May 31, 2009, at 11:58 AM, Benny Chain wrote:
> I am trying to rename the column names of a data frame called
> "data". It has
> 177 columns. I have used :
> colnames(data) <- a
> where a is a vector with 177 character names.
> I don't get any error message, but the column names don't change
> when I then type :
> I get the same set of names as before, so the assignment doesnt seem
> to have
> Any ideas or suggestions gratefully received.
> Benny Chain
> Benjamin Chain
> Division of Infection and Immunity
> Windeyer Building
> UCL, 46 Cleveland St.
> London W1T 4JF
> Fax 00 44 20 7679 9301
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help