Description Usage Arguments Value Author(s) Examples
grepl_multi
is a wrapper for grepl
that allows multiple inputs to the pattern
argument. Depending on the all
argument, it either returns whether each element of x
matches all or at least one of the patterns in patterns
. grepl_multi
inherits all the other parameters of grepl
.
1 2 3 |
patterns |
A character vector of regular expressions (or strings if |
x |
A character vector where matches are sought. |
all |
if |
... |
refer to |
a logical vector of the same length as x
Sven Halvorson (svenedmail@gmail.com)
1 2 3 4 5 6 7 8 | pat = letters[1:3]
strings = c("foo", "bar", "cabbie", "green chile")
# First we ask, which one of these stings have at least one of "a", "b", or "c"
cbind(strings,grepl_multi(patterns = pat, x = strings))
# Or we can ask, which strings have all three of "a", "b", and "c"
cbind(strings,grepl_multi(patterns = pat, x = strings, all = TRUE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.