Read a collection of CSV files into a single list object in R, and give each item in the list the name of the file from which it was read.
Created
March 31, 2014 03:00
-
-
Save lmullen/9884452 to your computer and use it in GitHub Desktop.
CSV files into a list of data frames
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
csv_files <- Sys.glob("data/*.csv") # See also list.files() | |
list_of_df <- lapply(csv_files, read.csv) | |
names(list_of_df) <- csv_files # Perhaps simplified with str_extract() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment