Last active
October 3, 2017 13:00
-
-
Save arcaravaggi/1abb4e19a20263b85cd7e488acd94ceb to your computer and use it in GitHub Desktop.
Read multiple csv files from one directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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