tor (version 1.1.2)

load_csv: Import multiple common files from a directory into an environment.

Description

These functions wrap common use-cases of load_any().

Usage

load_csv(
  path = ".",
  regexp = "[.]csv$",
  ignore.case = TRUE,
  invert = FALSE,
  envir = .GlobalEnv,
  ...
)

load_tsv( path = ".", regexp = "[.]tsv$", ignore.case = TRUE, invert = FALSE, envir = .GlobalEnv, ... )

load_rds( path = ".", regexp = "[.]rds$", ignore.case = TRUE, invert = FALSE, envir = .GlobalEnv )

load_rdata( path = ".", regexp = "[.]rdata$|[.]rda$", ignore.case = TRUE, invert = FALSE, envir = .GlobalEnv )

Arguments

path

A character vector of one path. Defaults to the working directory.

regexp

A regular expression (e.g. [.]csv$) passed on to grep() to filter paths.

ignore.case

if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching.

invert

If TRUE return files which do not match

envir

an environment or NULL.

...

Arguments passed to readr::read_csv() or readr::read_tsv().

Value

invisible(path).

See Also

Other functions to import files into an environment: load_any()

Other functions to import files of common formats: list_csv()

Examples

Run this code
# NOT RUN {
(path_csv <- tor_example("csv"))
dir(path_csv)

load_csv(path_csv)
# Each file is now available in the global environment
csv1
csv2

(path_mixed <- tor_example("mixed"))
dir(path_mixed)

# Loading the data in an environment other than the global environment
e <- new.env()
load_rdata(path_mixed, envir = e)
# Each dataframe is now available in the environment `e`
e$lower_rdata
e$upper_rdata
# }

Run the code above in your browser using DataLab