txt_grepl {udpipe} | R Documentation |
Look up a multiple patterns and indicate their presence in text
Description
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
.
Usage
txt_grepl(
x,
pattern,
FUN = all,
ignore.case = FALSE,
perl = FALSE,
fixed = FALSE,
useBytes = FALSE,
...
)
Arguments
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 |
Value
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
See Also
Examples
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")
[Package udpipe version 0.8.11 Index]