I have multiple .RData
in a folder. I can load them as follows:
df1 <- data.frame(X = 1:10)
df2 <- data.frame(X = 1:10)
save(df1, file = "df1.RData", compress = "xz")
save(df2, file = "df2.RData", compress = "xz")
rm(list = ls())
load("df1.RData")
load("df2.RData")
and bind them using bind_rows
function from dplyr
as
library(tidyverse)
bind_rows(df1, df2)
I wonder if it is possible to load all files and bind them something like this
list.files(
path = "."
, pattern = "*.RData"
, full.names = TRUE
) %>%
map_dfr(.x = ., .f = ~load(file = .x))