Learn R Programming

dirdf (version 0.0.0.9004)

dirdf: List Files in a Directory as a Data Frame

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

dirdf(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

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 dir().

See Also

dirdf_parse

Examples

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataLab