Last active
February 1, 2018 10:47
-
-
Save crsh/357458c41fd3d554fb24 to your computer and use it in GitHub Desktop.
Function to quickly rbind multiple local data-files
This file contains hidden or 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
batch_read <- function(path, pattern, recursive = FALSE, read_fun, ...) { | |
data.files <- list.files(path, pattern = pattern, recursive = recursive) | |
data <- lapply(paste0(path, data.files), read_fun, ...) | |
data <- do.call("rbind", data) | |
data | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Arguments
path
Character. Path to folder containing the data. Should end on/
.pattern
Character. Regular expression (file extension or other parts of the file name).read_fun
Function. Function used to read data files (e.g. read.csv)....
Other parameters passed toread_fun
.Example