Pretty extensible solution:
# test data: df1 <- data.frame(id=letters[1:2]) df2 <- data.frame(id=letters[1:2])
Collect your data into a list, then rbind
all at once:
dfs <- c("df1","df2") do.call(rbind, Map("[<-", mget(dfs), TRUE, "source", dfs) )
Also note in this example that when you rbind
using a named list, your socket names refer to the source data. This means that you can get almost what you want, simply:
dfs <- c("df1","df2") do.call(rbind, mget(dfs) ) # id #df1.1 a #df1.2 b #df2.1 a #df2.2 b
source share