I have 8 data frames that I want to add a column called \'park\', then fill this column in w/ a value that comes from the last four characters of the data
park
data
A variation using Map and some "[<-" trickery:
Map
"[<-"
vars <- ls(pattern="water_.") l <- mget(vars) names(l) <- substr(vars,nchar(vars)-3,nchar(vars)) do.call(rbind,Map("[<-",l,TRUE,"park",names(l)))