Re: [R] Define column names to a series of data.frames

2010-03-19 Thread Nikos Alexandris
Nikos Alexandris wrote: ... I have 6 data frames consisting of 6 rows x 7 columns put together from other data.frames. ... I want to give the following column names to each data.frame: (SDev, PC1, PC2, PC3, PC4, PC5, PC6) ... How is it to be done at once for all data.frames that the

Re: [R] Define column names to a series of data.frames

2010-03-12 Thread Gabor Grothendieck
Try this # set up test data # BOD1 and BOD2 are same as built in BOD BOD1 - BOD2 - BOD env - .GlobalEnv object.names - objects(pattern = BOD, env) # change col names of BOD1 to A B. Ditto for BOD2. for(nm in object.names) names(env[[nm]]) - c(A, B) On Thu, Mar 11, 2010 at 7:33 AM, Nikos

Re: [R] Define column names to a series of data.frames

2010-03-11 Thread Henrique Dallazuanna
You can try this: lapply(lapply(ls(pattern = 'DF[0-9]'), get), 'names-', c(SDev,PC1, PC2, PC3, PC4, PC5, PC6)) On Thu, Mar 11, 2010 at 9:33 AM, Nikos Alexandris nikos.alexand...@felis.uni-freiburg.de wrote: Greets to the list! I am aware that this topic has been discussed several

Re: [R] Define column names to a series of data.frames

2010-03-11 Thread Linlin Yan
It seems that the names of original data frames have not changed in this way. I guess textConnection() could help, like this: for (name in objects(pattern = df[0-9])) eval(parse(textConnection(paste('names(', name, ') - column_names' On Thu, Mar 11, 2010 at 9:25 PM, Henrique Dallazuanna

Re: [R] Define column names to a series of data.frames

2010-03-11 Thread Henrique Dallazuanna
Yes, just in the list. If they want change the name in Environment GlobalEnv: for(i in ls(pattern = DF[0-9])) assign(i, `names-`(get(i), c(SDev,PC1, PC2, PC3, PC4, PC5, PC6)), globalenv()) On Thu, Mar 11, 2010 at 10:39 AM, Linlin Yan yanlinli...@gmail.com wrote: It seems that the names

Re: [R] Define column names to a series of data.frames

2010-03-11 Thread Linlin Yan
Amazing! I haven't seen usage of calling `names-` like this before. Thanks so much! On Thu, Mar 11, 2010 at 9:50 PM, Henrique Dallazuanna www...@gmail.com wrote: Yes, just in the list. If they want change the name in Environment GlobalEnv:  for(i in ls(pattern = DF[0-9]))       assign(i,