batch_load: Load a large list of mixed files from a folder

batch_loadR Documentation

Load a large list of mixed files from a folder

Description

Quickly load a large mixed set of files into R environment.

Usage

batch_load(
  path,
  file_list,
  env = .GlobalEnv,
  haven_arg = list(),
  readxl_arg = list(),
  csv_arg = list(),
  fst_arg = list(),
  rds_arg = list(),
  readr = TRUE
)

Arguments

path

character vector defining the directory containing files to load.

file_list

character vector of files within directory to load.

env

R environment to assign data to; default set to .GlobalEnv.

haven_arg, readxl_arg, csv_arg, fst_arg, rds_arg

additional parameters passed to load functions depending on file extension.

readr

boolean value to determine if read_csv is used in preference to read.csv.

Details

This is only useful if all the files can be loaded with similar parameters. If certain columns or rows needs to be dropped during loading, then it may be best to load those separately. The use-case with the {relay} package is to provide a way to quickly take data files from a bundle into the environment. Loaded data will be assigned to the global environment by default with their names all in lower-case.

Files with the following extensions can all be loaded at the same time:

  1. sas7bdat via {haven}

  2. xlsx via {readxl}

  3. csv via {utils} or {readr}

  4. rds via {base}

Please note: when loading more troublesome/complex data, it may be easier to use the appropriate load functions directly.

Value

data-sets assigned to designated R environment.


al-obrien/relay documentation built on May 6, 2023, 10:19 p.m.