Ensure that all files in a vector are correctly named
Source:R/assert_name_pattern.R
assert_name_pattern.RdThis 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$
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.
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