Re: [R] lapply to change variable names and variable values

2012-03-12 Thread Simon Kiss
Thanks both! That solves ! You've made a very happy newbie! Simon On 2012-03-12, at 2:52 PM, Sarah Goslee wrote: > Hi Simon, > > On Mon, Mar 12, 2012 at 2:37 PM, Simon Kiss wrote: >> Hi: I'm sure this is a very easy problem. I've consulted Data Manipulation >> With R and the R Book and can't fi

Re: [R] lapply to change variable names and variable values

2012-03-12 Thread R. Michael Weylandt
Your function doesn't return the new data frame but rather the new names. Note, e.g. x <- 1:2 names(x) <- letters[1:2] .Last.value # Not x! Try this: .xx<- lapply(.xx, function(x) {colnames(x)<-c('State', 'Year'); x}) or more explicitly .xx<- lapply(.xx, function(x) {colnames(x)<-c('State', '

Re: [R] lapply to change variable names and variable values

2012-03-12 Thread Sarah Goslee
Hi Simon, On Mon, Mar 12, 2012 at 2:37 PM, Simon Kiss wrote: > Hi: I'm sure this is a very easy problem. I've consulted Data Manipulation > With R and the R Book and can't find an answer. > > Sample list of data frames looks as follows: > > .xx<-list(df<-data.frame(Var1=rep('Alabama', 400), Var2

Re: [R] lapply to change variable names and variable values

2012-03-12 Thread Steve Lianoglou
Hi, On Mon, Mar 12, 2012 at 2:37 PM, Simon Kiss wrote: > Hi: I'm sure this is a very easy problem. I've consulted Data Manipulation > With R and the R Book and can't find an answer. > > Sample list of data frames looks as follows: > > .xx<-list(df<-data.frame(Var1=rep('Alabama', 400), Var2=rep(c

[R] lapply to change variable names and variable values

2012-03-12 Thread Simon Kiss
Hi: I'm sure this is a very easy problem. I've consulted Data Manipulation With R and the R Book and can't find an answer. Sample list of data frames looks as follows: .xx<-list(df<-data.frame(Var1=rep('Alabama', 400), Var2=rep(c(2004, 2005, 2006, 2007), 400)), df2<-data.frame(Var1=rep('Tennes