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 Alexandris <nikos.alexand...@felis.uni-freiburg.de> wrote: > Greets to the list! > > I am aware that this topic has been discussed several times. And I've > read quite some related posts [1]. Yet, can't seem to give a solution to > my problem. > > I have 6 data frames consisting of 6 rows x 7 columns put together from > other data.frames. > > Something like: > > a b c d e f g > v1 # # # # # # # > v2 # # # # # # # > v3 # # # # # # # > v4 # # # # # # # > v5 # # # # # # # > v6 # # # # # # # > > > I want to give the following column names to each data.frame: ("SDev", > "PC1", "PC2", "PC3", "PC4", "PC5", "PC6") > > Works fine for one data.frame: > column_names <- c("SDev", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6") > names( df1 ) <- column_names > > How is it to be done at once for all data.frames that the function > objects(pattern = "SomePattern") can find? > > I've tried several things with assign, get, paste, for but I am not > getting anywhere. I need to integrate this in a function that can handle > lot's of data.frames and not only 6. > > Thank you, Nikos > > > --- > [1] I am stuck on this post: > <http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg32063.html>. > > It reads: > > dframes <- c("a","b","c") > cols <- c("one","two") > df <- data.frame(11:20, 21:30) > names(df) <- cols > assign(dframes[2], df) > > Can't understand the logic behind the "[2]". > > ______________________________________________ > 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. > ______________________________________________ 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.