Skip to content

Instantly share code, notes, and snippets.

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 KishoreNamala/92401e2741d6353a457f71ad3b13a2f8 to your computer and use it in GitHub Desktop.
Save KishoreNamala/92401e2741d6353a457f71ad3b13a2f8 to your computer and use it in GitHub Desktop.
Merge multiple csv files into a single data frame to work on
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