Do Subfolder List Elements Start with Given Folder Names?

starts_with_parts(parts, elements)

Arguments

parts

list of list of character as returned by split_paths or a matrix of character representing the subfolder names at the different folder depths as returned by to_subdir_matrix.

elements

vector of character giving the sequence of strings to be found in parts

Value

vector of logical as long as parts containing TRUE at positions i for which all(parts[[i]][seq_along(elements)] == elements) is TRUE

Examples

parts <- strsplit(c("a/b/c", "a/b/d", "b/c"), "/") starts_with_parts(parts, elements = c("a", "b"))
#> [1] TRUE TRUE FALSE
starts_with_parts(parts, elements = c("b", "c"))
#> [1] FALSE FALSE TRUE
subdir_matrix <- kwb.file::to_subdir_matrix(parts) starts_with_parts(subdir_matrix, elements = c("a", "b"))
#> [1] TRUE TRUE FALSE
starts_with_parts(subdir_matrix, elements = c("b", "c"))
#> [1] FALSE FALSE TRUE