Read Multiple Files & Append into Dataframe

Hi,

I would like to read multiple files (RDS dataframes) from my shiny app and append them into one dataframe. Hard for me to reprex here since files are on my HD, but looking for an elegant solution, guidance. Is it possible to use an apply function or should i use loops?

I have the file paths in a vector:

filepaths <- c(f1, f2, f2...)

but not sure how to readRDS then rbind as one line of code to get a dataframe of all file data.

Thanks

Hi, something like this perhaps? Reading and combining many tidy data files in R | Claus O. Wilke (clauswilke.com)

thanks, I was trying to stick to apply or loops, and came up with the working structure below - this works, but I don't have a reprex sicne files are not available:

r_lc_load <- reactive({
req(input$r_lc_file1)
files <- c(input$r_lc_file1$datapath)
d <- list()

for (i in 1:length(files)) 
{
  d[[i]]  <- readRDS(files[i])
}
d1  <- dplyr::bind_rows(d)

})

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.