Read and combine multiple data files. The files will be merged into one data.frame.

  directory = ".",
  subdirectories = FALSE,
  extension = NULL,
  data = NULL,
  verbose = TRUE,
  fun = utils::read.csv,



a character string. Name of the folder where the raw data are stored. If it does not contain an absolute path, the file name is relative to the current working directory. Defaults to current working directory.


logical indicating whether the directory contains subdirectories. If FALSE (the default), it is assumed that all raw data files are directly included in the directory. If TRUE, it is assumed that the raw data files are stored in folders within the directory. Alternatively, a vector of folder names that contain the raw data.


an optional character string. If specified, only files ending with the specified extension will be merged.


A data.frame to which the new data will be added. This is optional, and an empty data.frame is used if none is provided.


logical indicating whether function should report its progress.


the function used for reading the individual files. By default, this is read.csv. Can be any data import function as long as it takes the file name as first argument.


additional arguments passed on to fun.


A data.frame containing the merged data.

One column in the data.frame (File) contains the name of the raw data file. If the subdirectories option is set, an additional column (Subdirectory) with the name of the subdirectory is added.


read_bulk provides a wrapper around a specific data import function (read.csv by default) to load the individual data files. After loading, the different data files are merged using rbind.fill. This function can deal with varying column names across files, and still places data into the appropriate columns. If a column is not present in a specific file, it will be filled with NA.

See also

read.table for reading individual data files.

rbind.fill is responsible for merging files.

write.table for data export.


if (FALSE) { # Merge all files in the main folder "raw_data" # (which is in the current working directory) raw_data <- read_bulk(directory = "raw_data") # Merge files with file extension ".csv" raw_data <- read_bulk(directory = "raw_data", extension = ".csv") # Merge all files stored in separate folders # within the folder "raw_data" raw_data <- read_bulk(directory = "raw_data", subdirectories = TRUE) # Merge all raw data stored in the folders "Session1" # and "Session2" within the folder "raw_data" raw_data <- read_bulk(directory = "raw_data", subdirectories = c("Session1","Session2")) # Merge tab separated data files and prevent # character vectors from being converted to factors raw_data <- read_bulk(directory = "raw_data", fun=read.delim,stringsAsFactors=FALSE) }