Re: [R] Change the name of one column ONLY

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Wed, 09 Jun 2010 16:55:06 -0300

Try:

names(x)[1] <- 'pears'

On Wed, Jun 9, 2010 at 2:45 PM, Josh B <joshb41_at_yahoo.com> wrote:

> Hi all,
>
> I have a very simple problem that I cannot seem to find the answer to.
> Consider the following toy dataset:
>
> x <- read.table(textConnection("V1 apples bananas cherries
> indv.1 7 8 4 3
> indv.2 7 7 4 9"), header = TRUE)
>
> How would I change the column name of ONLY the first column, not the
> others? Surely I should not have to re-specify the names of ALL the columns
> -- e.g., colnames(x) <- c("pears", "apples", "bananas", "cherries") -- if
> only the first column name will change.
>
> Thanks very much,
> Josh
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


______________________________________________ R-help_at_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.

Received on Wed 09 Jun 2010 - 20:00:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Jun 2010 - 20:00:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive