rbind data frames based on a common pattern in data frame name

Solution 1:

We can use ls with mget

library(data.table)
rbindlist(mget(ls(pattern = "^df\\.\\d+")))

Or with dplyr

library(dplyr)
mget(ls(pattern="^df\\.\\d+")) %>%
              bind_rows()

Or with rbind from base R

do.call(rbind, mget(ls(pattern="^df\\.\\d+")))

Solution 2:

You can try:

new_df <- do.call("rbind",mget(ls(pattern = "^df.*")))