txt_grepl | R Documentation |
A variant of grepl
which allows to specify multiple regular expressions
and allows to combine the result of these into one logical vector.
You can specify how to combine the results of the regular expressions by specifying
an aggregate function like all
, any
, sum
.
txt_grepl( x, pattern, FUN = all, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE, ... )
x |
a character vector |
pattern |
a character vector containing one or several regular expressions |
FUN |
a function to apply to combine the results ot the different regular expressions for each element of |
ignore.case |
passed on to |
perl |
passed on to |
fixed |
passed on to |
useBytes |
passed on to |
... |
further arguments passed on to |
a logical vector with the same length as x
with the result of the call to FUN
applied elementwise to each result of grepl for each pattern
grepl
x <- c("--A--", "--B--", "--ABC--", "--AC--", "Z") txt_grepl(x, pattern = c("A", "C"), FUN = all) txt_grepl(x, pattern = c("A", "C"), FUN = any) txt_grepl(x, pattern = c("A", "C"), FUN = sum) data.frame(x = x, A_and_C = txt_grepl(x, pattern = c("A", "C"), FUN = all), A_or_C = txt_grepl(x, pattern = c("A", "C"), FUN = any), A_C_n = txt_grepl(x, pattern = c("A", "C"), FUN = sum)) txt_grepl(x, pattern = "A|C")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.