[R] Change One Column Name in Data Frame

R. Michael Weylandt michael.weylandt at gmail.com
Tue May 15 18:40:28 CEST 2012


x <- data.frame(a = 1:5, b = rnorm(5))

colnames(x)

colnames(x)[2] <- "Cow"

x

HTH,
Michael

On Tue, May 15, 2012 at 12:30 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
>  The data frame has 61 columns and one column name needs to be changed. The
> colnames() function can be used to change all of them when passed a vector
> of names, but can it also change a single name? If not, is there a way to
> change just the one column name?
>
> Rich
>
> ______________________________________________
> 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.



More information about the R-help mailing list