Skip to contents

A cr_path_spec holds everything needed to recover design facts from where a file sits and what it is called: the meaning of each directory level, the file-name grammar, the marker rules and whether an unparseable name is an error.

Usage

cr_path_spec(levels = NULL, grammar = NULL, markers = NULL, strict = TRUE)

# S3 method for class 'cr_path_spec'
print(x, ...)

Arguments

levels

Either an unnamed character vector naming the directory levels below the root in order (use NA or "" to skip a level), or a named integer vector mapping column names to level indices, where negative indices count back from the file (-1 is the directory containing the file).

grammar

A cr_filename_grammar(), or NULL.

markers

A cr_marker_rules() object, or NULL.

strict

Logical. Treat a file name that does not match the grammar as an error. Default TRUE.

x

A cr_path_spec.

...

Ignored.

Value

An object of class cr_path_spec (a list).

x, invisibly.

Examples

spec <- cr_path_spec(
  levels = c(run = 1L, compound = 2L, plate = -1L),
  grammar = cr_filename_grammar(
    tokens = list(interval = "[0-9]+min", dose = "[0-9]+uM")
  ),
  markers = cr_marker_rules(merge_unit = "\\(split\\)")
)
spec
#> <cr_path_spec>
#> • levels: run[1] / compound[2] / plate[-1]
#> • grammar tokens: interval, dose
#> • markers: set
#> • strict: TRUE