make_or_pattern | R Documentation |
This function makes "or" regex patterns from vectors or lists of strings.
This function can be used with the matsbyname::select_rows_byname()
and matsbyname::select_cols_byname
functions.
make_or_pattern()
correctly escapes special characters in strings
,
such as (
and )
, as needed.
Thus, it is highly recommended that make_or_pattern
be used when
constructing patterns for row and column selections with
matsbyname::select_rows_byname()
and matsbyname::select_cols_byname()
.
make_or_pattern(
strings,
pattern_type = c("exact", "leading", "trailing", "anywhere", "literal")
)
strings |
A vector of row and column names. |
pattern_type |
One of "exact", "leading", "trailing", "anywhere", or "literal". Default is "exact". |
pattern_type
controls the type of pattern created:
exact
produces a regex pattern that selects row or column names by exact match.
leading
produces a regex pattern that selects row or column names if the item in strings
matches
the beginnings of row or column names.
trailing
produces a regex pattern that selects row or column names if the item in strings
matches
the ends of row or column names.
anywhere
produces a regex pattern that selects row or column names if the item in strings
matches
any substring of row or column names.
literal
returns strings
unmodified, and it is up to the caller to formulate a correct regex.
An "or" regex pattern suitable for selecting row and column names.
Amenable for use with matsbyname::select_rows_byname
or matsbyname::select_cols_byname
.
make_or_pattern(strings = c("a", "b"), pattern_type = "exact")
make_or_pattern(strings = c("a", "b"), pattern_type = "leading")
make_or_pattern(strings = c("a", "b"), pattern_type = "trailing")
make_or_pattern(strings = c("a", "b"), pattern_type = "anywhere")
make_or_pattern(strings = c("a", "b"), pattern_type = "literal")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.