Skip to content
Prev 288110 / 398498 Next

lapply to change variable names and variable values

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', 'Year');  return(x)})

Michael
On Mon, Mar 12, 2012 at 2:37 PM, Simon Kiss <sjkiss at gmail.com> wrote: