Skip to content

Instantly share code, notes, and snippets.

@Nicktz
Created November 23, 2015 13:02
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 Nicktz/8404fc914c9886ca5614 to your computer and use it in GitHub Desktop.
Save Nicktz/8404fc914c9886ca5614 to your computer and use it in GitHub Desktop.
Using lapply to import a list of csv's using read_csv
The following imports a long list of csv's fast using lapply and read_csv:
# File list:
data.files <- list.files(production.dataset(Universe,"EQS"),pattern = "*.csv",full.names=TRUE, recursive = FALSE, include.dirs = FALSE)
# Import all the files as separate lists
df.eqs <- lapply( data.files, function(x) read_csv(x))
# Append the files by row:
x <- df.eqs[[1]]
for(i in 2:length(df.eqs)){
x <- bind_rows(x,df.eqs[[i]])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment