Skip to contents

This function runs a list of file names through a pattern check. A warning will be returned in case not all file names pass the check. Offending file names will be shown. Maria: your specific pattern is defined as "^Sc\\d\\d\\.Pl\\d\\d\\d\\.Ma\\d\\.S[AB]\\.An\\d\\d\\.Pb\\.Dir(Fo|Ba)\\.\\Siz[SML](|.mid)\\.x3p$

Usage

assert_name_pattern(file, pattern, verbose = FALSE)

Arguments

file

(vector of) file name(s)

pattern

format for a study, generally in regular expression. See e.g. https://regexr.com/ for help in creating suitable patterns

verbose

logical value whether function chatters for re-assurance when things works. Defaults to FALSE.

Value

vector of indices of files that don't pass the check

Examples

files <- dir("data-raw", pattern=".x3p", recursive = TRUE, full.names=FALSE)
assert_name_pattern(files, pattern="^T\\d\\d[SML][AB]-[FB][678]0-0[1-8].x3p$")
#> Warning: 2 file(s) do not match pattern <^T\d\d[SML][AB]-[FB][678]0-0[1-8].x3p$>:
#> 'NA'
#> [1] 1 0