Re: [R] rename cols

From: Ethan Johnsons <ethan.johnsons_at_gmail.com>
Date: Tue 12 Sep 2006 - 17:52:21 GMT

Thank you so much!!

ej

On 9/11/06, Tony Plate <tplate@acm.org> wrote:
>
> The following works for data frames and matrices (you didn't say which
> you were working with).
>
> > x <- data.frame(V1=1:3,V2=4:6)
> > x
> V1 V2
> 1 1 4
> 2 2 5
> 3 3 6
> > colnames(x) <- c("Apple", "Orange")
> > x
> Apple Orange
> 1 1 4
> 2 2 5
> 3 3 6
> >
>
> For a data frame, 'names(x) <- c("Apple", "Orange")' also works, because
> a dataframe is stored internally as a list of columns.
>
> -- Tony Plate
>
> Ethan Johnsons wrote:
> > A quick question please!
> >
> > How do you rename column names? i.e. V1 --> Apple; V2 --> Orange, etc.
> >
> > thx much
> >
> > ej
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch 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.
> >
>
>

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch 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 Sep 13 17:19:35 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 13 Sep 2006 - 08:30:05 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.