try this:
colnames(df)<-df_names[1:ncol(df),"name"]

On Sun, Dec 23, 2012 at 8:41 PM, radhi <radhikum...@yahoo.in> wrote:

> Hi, I've got a dataframe having a code as column name. Addtionally I have
> another dataframe with a two columns (and lots of rows), the first
> containing the code and the second some Text (real name). Now I'd like to
> use the information (pairs of code and name) of the second dataframe to
> rename all the columnnames in the first dataframe. How is it possible to
> achieve that? Here a small example of the two dataframes: df <-
> data.frame(A=(1:10),B=(1:10),C=(1:10)) df_names <-
> data.frame(code=c("A","B","C","D","E"),name=c("Col A","Col B","Col C","Col
> D","Col E"))  click here <http://totalltelugumovies.blogspot.in>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Renaming-column-names-according-to-another-dataframe-tp4653824.html
> Sent from the R help mailing list archive at Nabble.com.
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to