Created
June 12, 2014 12:18
-
-
Save nskeip/9eef7db6b76c43849a83 to your computer and use it in GitHub Desktop.
Read multiple CSV files into a single dataframe
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
create_big_data_from_csv_dir <- function(directory, ids) { | |
# locate the files | |
files <- list.files(directory, full.names=T)[ids] | |
# read the files into a list of data.frames | |
data.list <- lapply(files, read.csv) | |
# concatenate into one big data.frame | |
data.cat <- do.call(rbind, data.list) | |
# aggregate | |
# data.agg <- aggregate(value ~ index, data.cat, mean) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing! I added a parameter to alternatively load lists from JSON files into a combined list iteam, instead of CSV files. Can be enabled by calling
getAllInDir("directoryOfJSONs", asList = TRUE)
. I also removed ids parameter for my use case.