tor (version 1.0.1)

list_any: Read multiple files into a list with your favorite reader function.

Description

Read multiple files into a list with your favorite reader function.

Usage

list_any(path = ".", .f, regexp = NULL, ignore.case = FALSE,
  invert = FALSE, ...)

Arguments

path

A character vector of one or more paths.

.f

A function able to read the desired file format.

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

...

Additional arguments passed to grep.

Value

A list.

See Also

Other general functions to import data: list_csv, load_csv

Examples

Run this code
# NOT RUN {
tor_example()

path <- tor_example("csv")
dir(path)

list_any(path, read.csv)

list_any(path, ~ read.csv(.x, stringsAsFactors = FALSE))

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

list_any(
  path_mixed, ~ get(load(.x)),
  regexp = "[.]csv$",
  invert = TRUE
)

list_any(
  path_mixed, ~ get(load(.x)),
  "[.]Rdata$",
  ignore.case = TRUE
)
# }

Run the code above in your browser using DataLab