rd: Read files form a directory by a given function

Description Usage Arguments Examples

View source: R/rd.R

Description

Read multiple files from a directory (folder) using reading engine supply by a function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
rd(
  .f,
  path = ".",
  pattern = "\\.csv$",
  ...,
  invert = F,
  ignore.case = F,
  perl = F,
  fixed = F,
  all.files = F,
  recursive = F,
  no.. = F,
  snake_case = F
)

Arguments

.f

A function to read files from a directory. First argument of the function must be file path. Support formula interface. Example : utils::read.csv, readr::read_csv, rio::import, readxl::read_excel, base::readRDS

path

Character: Path to desired directory which contain file, default is "." working directory. (passed to base::list.files)

pattern

Character: Specify regular expression to match file extension and file names. (passed to grep()) . Default is to read .csv file "\.csv$". Please select according to fun; Example, use \\.xlsx$ to read from excel file.

...

Argument to pass to .f

invert

Logical: If TRUE read from file that file names do not match pattern.(passed to grep())

ignore.case

If FALSE, the regular expression matching is case sensitive and if TRUE, case is ignored during matching.(passed to grep())

perl

Logical: Should Perl-compatible regexps be used? (passed to grep())

fixed

Logical: If TRUE, pattern is a string to be matched as is. Overrides all conflicting arguments.

all.files

If TRUE hidden files are also returned. (passed to base::list.files)

recursive

If TRUE read recursively in sub-directory.(passed to base::list.files)

no..

logical. Should both "." and ".." be excluded also from non-recursive listings? (passed to base::list.files)

snake_case

If TRUE: Convert names to snake_case_format. (require snakecase package)

Examples

1
 if(FALSE){ "Under development" }

Lightbridge-AI/lbr documentation built on Dec. 27, 2021, 8:09 p.m.