dirdf: List Files in a Directory as a Data Frame

Description Usage Arguments See Also Examples

View source: R/dirdf.R

Description

Creates a data frame using information from paths and file names. It searches through the directories in order to create the path names of the files. It accepts either a template or a regular expression and column names.

Usage

1
2
3
4
5
dirdf(paths, template = NULL, regexp = NULL, colnames = NULL,
  missing = NA_character_, recursive = TRUE, ...)

dirdf2(paths, template = NULL, regexp = NULL, colnames = NULL,
  missing = NA_character_, recursive = TRUE, ...)

Arguments

paths

character vector with zero or more paths that will be searched.

template

template character string, e.g. "Country/Province/City/StationID_Date.ext".

regexp

regular expression used to parse the file names. Only one of the arguments regexp and template must be specified, i.e. only one of them can be non-NULL.

colnames

character vector containing the names of the columns in the data frame. Not required if using template or if regexp uses named capturing groups (see examples), but may still be used to override column names.

missing

value to use for unmatched optional template elements or regexp capturing groups.

recursive

if TRUE, it will recursively search over directories.

...

Additional arguments pass to base::dir().

See Also

dirdf_parse()

Examples

1
2
3
4
5
6
7
8
9
path1 <- system.file(package = "dirdf", "examples", "dataset_1")
template1 <- "Year-Month-Day_Assay_Plasmid-Type-Fraction_WellNumber?.extension"
files1 <- dirdf(path1, template = template1)
print(files1)

path2 <- system.file(package = "dirdf", "examples", "dataset_2")
template2 <- "Date_Assay_Experiment_WellNumber?.extension"
files2 <- dirdf(path2, template = template2)
print(files2)

ropenscilabs/dirdf documentation built on July 25, 2018, 10:37 p.m.