Description Usage Arguments See Also Examples
Creates a data frame using information from the paths and file names. It
accepts either a template or a regular expression and column names. Similar
to dirdf()
, but this takes a vector of pathnames and tries to
match them directly, rather than calling base::dir()
on them and
matching those results. This is helpful if you want to filter or transform
the set of paths before matching, e.g. to remove any irrelevant filenames
like ‘.gitignore’, ‘.DS_Store’, ‘desktop.ini’.
1 2 | dirdf_parse(pathnames, template = NULL, regexp = NULL, colnames = NULL,
missing = NA_character_, ignore.case = FALSE, perl = TRUE)
|
pathnames |
character vector of pathname(s), e.g. the result of calling
|
template |
template character string, e.g.
|
regexp |
regular expression used to parse the file names.
Only one of the arguments |
colnames |
character vector containing the names of the columns in the
data frame. Not required if using |
missing |
value to use for unmatched optional template elements or regexp capturing groups. |
ignore.case, perl |
If |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | path1 <- system.file(package = "dirdf", "examples", "dataset_1")
pathnames1 <- dir(path1)
template1 <- "Year-Month-Day_Assay_Plasmid-Type-Fraction_WellNumber?.extension"
regex1 <- paste0(
"^(?P<Year>\\d{4})-(?P<Month>\\d{2})-(?P<Day>\\d{2})",
"_(?P<Assay>[a-zA-Z0-9]+)_(?P<Plasmid>[a-zA-Z0-9]+)",
"-(?P<Type>[a-zA-Z0-9]+)-(?P<Fraction>[a-zA-Z0-9\\-]+)",
"(?:_(?P<WellNumber>\\w+))?\\.csv$"
)
regex1a <- paste0(
"^(\\d{4})-(\\d{2})-(\\d{2})_([a-zA-Z0-9]+)_([a-zA-Z0-9]+)",
"-([a-zA-Z0-9]+)-([a-zA-Z0-9\\-]+)(?:_(\\w+))?\\.csv$"
)
names_regex1a <- c("Year", "Month", "Day", "Assay", "Plasmid", "Type", "Fraction", "WellNumber")
dirdf_parse(pathnames1, template1)
dirdf_parse(pathnames1, regexp = regex1)
dirdf_parse(pathnames1, regexp = regex1a, colnames = names_regex1a)
path2 <- system.file(package = "dirdf", "examples", "dataset_2")
pathnames2 <- dir(path2)
template2 <- "Date_Assay_Experiment_WellNumber?.extension"
dirdf_parse(pathnames2, template2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.