Skip to contents

Reads a series of either .xlsx or .csv files into a table. Particularly useful when reading in multiple files having the same variables, for example reading in data from an experiment where data was logged and saved separately for each individual unit. Integration of a custom data cleaning function.

Usage

load_files(
  folder,
  filetype = ".csv",
  data_cleaning_function = NULL,
  id_by_filename = FALSE,
  id_col_name = "index"
)

Arguments

folder

Folder where the files to be read in are located (required)

filetype

Set whether to read in .xlsx or .csv files. It takes either ".xlsx" or ".csv". By default, it is set to ".csv" (required)

data_cleaning_function

Add a custom data cleaning function built for individual files. Use no brackets when referencing the function, for example clean_data_from_data_logger. The function being added must be saved in the environment (optional)

id_by_filename

Logical. If set to TRUE, the output will contain a column, storing the name of each file being read in. Ideally, the names of the individual files should be pertinent to their content, e.g. if 20 files are being read in with experimental data from parts 1 through 20, the files should be named 1-20. (optional)

id_col_name

Specify a name for the .id column. By default, it is set to "index" (optional)

Value

Returns data in the form of a tibble object.