list_any: Import multiple files of any format from a directory into a...

Description Usage Arguments Value See Also Examples

View source: R/list_any.R

Description

Import multiple files of any format from a directory into a list.

Usage

1
2
3
4
5
6
7
8
list_any(
  path = ".",
  .f,
  regexp = NULL,
  ignore.case = FALSE,
  invert = FALSE,
  ...
)

Arguments

path

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

.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 .f.

Value

A list.

See Also

Other functions to import files into a list: list_csv()

Other functions to import files of any format: load_any()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)),
  "[.]Rdata$",
  ignore.case = TRUE
)

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

tor documentation built on March 26, 2020, 7:29 p.m.