Reputation: 968
I have a vector with some dataframe names:
myvector<-c('a', 'b', 'c', 'd')
Now, in a for loop, I would like to do some manipulation to each dataframe named with 'myvector' elements, so I would like to unquote its elements.
myvector2<-c(a, b, c, d)
Thanks!
Upvotes: 2
Views: 391
Reputation: 389315
You could use get
to get a single dataframe in a loop.
for (vec in myvector) {
df <- get(vec)
#Do some stuff
}
Or use mget
to get list of dataframes and then apply some function with lapply
.
lapply(mget(myvector), function(x) {
#Do some stuff
})
Upvotes: 1