Re: [R] Renaming column names according to another dataframe

2012-12-26 Thread Heramb Gadgil
try this: colnames(df)<-df_names[1:ncol(df),"name"] On Sun, Dec 23, 2012 at 8:41 PM, radhi 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

[R] Renaming column names according to another dataframe

2012-12-23 Thread radhi
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 t

Re: [R] Renaming column names according to another dataframe

2012-12-11 Thread arun
f_names$name[match(names(df),df_names$code)] A.K. - Original Message ----- From: Johannes Radinger To: r-help@r-project.org Cc: Sent: Tuesday, December 11, 2012 5:55 AM Subject: [R] Renaming column names according to another dataframe Hi, I've got a dataframe having a code as column n

Re: [R] Renaming column names according to another dataframe

2012-12-11 Thread arun
ing column names according to another dataframe 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 (

Re: [R] Renaming column names according to another dataframe

2012-12-11 Thread Johannes Radinger
A","Col > B","Col D","Col E","Col C")) > > names(df)<-df_names$name[match(names(df),df_names$code)] > > > A.K. > > - Original Message - > From: Johannes Radinger > To: r-help@r-project.org > Cc: > Sent: Tue

Re: [R] Renaming column names according to another dataframe

2012-12-11 Thread Anthony Damico
df <- data.frame(A=(1:10),B=(1:10),C=(1:10)) # my changes to show that order doesn't matter df_names <- data.frame(code=c("C","A","D","E","B"),name=c("Col C","Col A","Col D","Col E","Col B")) names( df ) <- df_names[ match( names( df ) , df_names[ , 'code' ] ) , 'name' ] for more detail see ?mat

[R] Renaming column names according to another dataframe

2012-12-11 Thread Johannes Radinger
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