Description Usage Arguments Value Author(s) See Also Examples
mgrepl
allows multiple patterns search in character vectors,
offering multicore support to parallelize search over all patterns
using mclapply.
1 2 |
patterns |
A vector or list containing regular expressions
(regex) to be searched in |
text |
Character vector on which the search is performed. |
log.fun |
A function to apply on the result of matching each pattern
on each element of |
na.replace |
A single value to replace each |
use.which |
A logical value.
|
cores |
Numeric value for how many cores to use for computation using
|
... |
Further arguments passed to functions grepl. |
Depending on the function defined with log.fun
, the return value is either
a vector
, e.g. for functions like any, all or sum.
a matrix
is obtained with e.g. identity or as.integer. Each
row holds the result of a single pattern.
a list
is returned for functions which create results of different lengths
for each element, such as which.
Sven E. Templer
grepl, mclapply
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #
# strings
s <- c("ab","ac","bc", NA)
# match all patterns (default)
mgrepl(c("a", "b"), s)
# match any of the patterns
mgrepl(c("a", "b"), s, any)
grepl("a|b", s)
# return logical matrix, one column for each pattern
mgrepl(c("a", "b"), s, identity)
# return count of matches
mgrepl(c("a", "b"), s, sum)
#
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.