
Last chance! 50% off unlimited learning
Sale ends in
mgrepl
searches for any or all patterns and returns logical values.
Combination of the results is done via the logic functions any
,
all
or identity
, for example.
Multicore feature is made available by parallel::mclapply
.
mgrepl(patterns, text, log.fun = any, use.which = FALSE, cores = 1, ...)
text
.any
or all
)
to evaluate occurence of each pattern in patterns
in each
value of text
. Can also be custom. See examples.TRUE
to return an integer like which
instead a logical vector.mclapply
.grepl()
, sub()
and gsub()
.text
where TRUE
means either
any or all patterns in patternlist
are matched in text
depending on log.fun
.
Using identity
as logical returns a matrix with results of patterns per row.
#
# Compare different "log.fun" parameters:
mgrepl(c("a","b"), c("ab","ac","bc"), any)
mgrepl(c("a","b"), c("ab","ac","bc"), all)
mgrepl(c("a","b"), c("ab","ac","bc"), all, use.which = TRUE)
mgrepl(c("a","b"), c("ab","ac","bc"), identity)
mgrepl(letters[1:3], c("ax","xab","xbc"), function (x) sum(x)>1)
#
Run the code above in your browser using DataLab