# This is accompanying code for # https://jozef.io/r005-import-csvs/ data_dir <- path.expand("data/r005/ie-general-referrals-by-hospital") filePaths <- list.files(data_dir, "\\.csv$", full.names = TRUE) result <- do.call(rbind, lapply(filePaths, function(path) { df <- read.csv(path, stringsAsFactors = FALSE) df[["source"]] <- rep(path, nrow(df)) df[["Month_Year"]] <- as.Date( paste0(sub("-20", "-", df[["Month_Year"]], fixed = TRUE), "-01"), format = "%b-%y-%d" ) df })) q(save = "no", status = 0)