[R] change column names of several data frames

2008-04-21 Thread Henrik Parn
Dear all, I have several data frames for which I want to change the column names. Example data: data.1 - data.frame(x1 = rnorm(5)) data.2 - data.frame(x1 = rnorm(5)) . . What I want to achieve: names(data.1) - y1 names(data.1) - y1 . . Is it possible to achieve this with a loop or any of the

Re: [R] change column names of several data frames

2008-04-21 Thread Antonio, Fabio Di Narzo
Henrik Parn henrik.parn at bio.ntnu.no writes: Dear all, I have several data frames for which I want to change the column names. Example data: data.1 - data.frame(x1 = rnorm(5)) data.2 - data.frame(x1 = rnorm(5)) Use lists. I.e.: data - list() data[[1]] - data.frame(x1 = rnorm(5))

Re: [R] change column names of several data frames

2008-04-21 Thread Wolfgang Huber
Hi Henrik, afaIcs this should work: for(v in sprintf(data.%d, 1:n)) { f = get(v) names(f) = whatever assign(v, f) } -- Best wishes Wolfgang -- Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber

Re: [R] change column names of several data frames

2008-04-21 Thread David Scott
On Mon, 21 Apr 2008, Henrik Parn wrote: Dear all, I have several data frames for which I want to change the column names. Example data: data.1 - data.frame(x1 = rnorm(5)) data.2 - data.frame(x1 = rnorm(5)) . . What I want to achieve: names(data.1) - y1 names(data.1) - y1 . . Is