Created
March 28, 2018 23:17
-
-
Save KishoreNamala/92401e2741d6353a457f71ad3b13a2f8 to your computer and use it in GitHub Desktop.
Merge multiple csv files into a single data frame to work on
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
multiple_csvfiles_2_dataframe <- function(directory) { | |
#read the file names from the input directory for all CSVs | |
filenames <- list.files(directory, pattern="*.csv", full.names=TRUE) | |
# create a list by reading csv files | |
dfs.list <- lapply(filenames,read.csv) | |
# Create a single data frame from the list | |
df <- do.call(rbind,dfs.list) | |
#Return the data frame | |
df | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment