Skip to content

Instantly share code, notes, and snippets.

@arcaravaggi
Last active October 3, 2017 13:00
Show Gist options
  • Save arcaravaggi/1abb4e19a20263b85cd7e488acd94ceb to your computer and use it in GitHub Desktop.
Save arcaravaggi/1abb4e19a20263b85cd7e488acd94ceb to your computer and use it in GitHub Desktop.
Read multiple csv files from one directory
# Read in all csv files in directory
files <- list.files(pattern = "*.csv")
# Create dfs for each csv then create list
for (i in 1:length(files))
assign(files[i],
read.csv(files[i]))
lst <- mget(ls(pattern = "*.csv"))
# Alternatively, read cvs directly into list
lst <- sapply(files, read.csv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment