1

I have a set of .rds files for each day. Each file is of the format "xyz_yyyy_mm_dd.rds". Now i want to take files for the last 30 days and append them into a single file in R. I absolutely have no idea how this is done. Hence, please provide complete solution.

  • Please see the following two help pages: https://stackoverflow.com/help/how-to-ask and https://stackoverflow.com/help/mcve – hannes101 Jul 02 '18 at 14:10

1 Answers1

0

Try out something like this:

setwd("C:/where/your/files/are")
file_list <- list.files(".", pattern = "*.rds")
combinded <- readRDS(file_list[1])
for(i in 2:length(file_list)){
    int <- readRDS(file_list[i])
    combinded <- c(combinded, int)
}

Or something like this instead of the for loop:

combinded <- unlist(lapply(file_list, readRDS))
AndS.
  • 7,748
  • 2
  • 12
  • 17
  • I want to consider only files for the last 30 days. The location will have files for the last 4 years and I don't want to append all of them. I somehow have to extract date from the file name and limit the date to last 30 days. – Jesse Sundar Jul 03 '18 at 09:05