Description Usage Arguments Details Value Examples
Detect matching pattern in character vector.
1 | chr_detect(x, pat, ignore.case = FALSE, ...)
|
x |
Character vector |
pat |
Pattern (regex) to detect from text. |
ignore.case |
Logical indicating whether to ignore capitalization. Defaults to false. |
... |
Other named arguments passed to |
This is a wrapper around the base R functions grepl
and
grep
. By default, logical values are returned (a la grepl). To return
values, include value = TRUE
. To return positions, include which = TRUE
,
pos = TRUE
, or position = TRUE
.
Logical vector indicating whether each element matched the supplied pattern.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## return logical vector
chr_detect(letters, "a|b|c|x|y|z")
## return inverted logical values
chr_detect(letters, "a|b|c|x|y|z", invert = TRUE)
## return matching positions
chr_detect(letters, "a|b|c|x|y|z", which = TRUE)
## return inverted matching positions
chr_detect(letters, "a|b|c|x|y|z", which = TRUE, invert = TRUE)
## return matching values
chr_detect(letters, "a|b|c|x|y|z", value = TRUE)
## return inverted matching values
chr_detect(letters, "a|b|c|x|y|z", value = TRUE, invert = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.