Skip to content

Instantly share code, notes, and snippets.

@lmullen
Created March 31, 2014 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmullen/9884452 to your computer and use it in GitHub Desktop.
Save lmullen/9884452 to your computer and use it in GitHub Desktop.
CSV files into a list of data frames

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.

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