Skip to content

Instantly share code, notes, and snippets.

@ksonda
Last active February 18, 2022 01:34
Show Gist options
  • Save ksonda/4d0f9a096afc13f86445f28f54de9887 to your computer and use it in GitHub Desktop.
Save ksonda/4d0f9a096afc13f86445f28f54de9887 to your computer and use it in GitHub Desktop.
combine csvs in R
library(readr)
library(dplyr)
csv_directory <- "."
output_directory <- "./results"
filenames <- list.files(csv_directory,pattern="*.csv")
all_files <- Reduce(bind_rows, lapply(filenames, read_csv, col_types = cols(.default = "c")))
write_csv(all_files, paste0(output_directory,"/all_files.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment