txt_contains | R Documentation |
Look up text which has a certain pattern. This pattern lookup is performed by executing a regular expression using grepl
.
txt_contains(x, patterns, value = FALSE, ignore.case = TRUE, ...)
x |
a character vector with text |
patterns |
a regular expression which might be contained in |
value |
logical, indicating to return the elements of |
ignore.case |
logical, if set to |
... |
other parameters which can be passed on to |
a logical vector of the same length as x
indicating if one of the patterns was found in x
.
Or the vector of elements of x
where the pattern was found in case argument value
is set to TRUE
grepl
x <- c("The cats are eating catfood", "Our cat is eating the catfood", "the dog eats catfood, he likes it", NA) txt_contains(x, patterns = c("cat", "dog")) txt_contains(x, patterns = c("cat", "dog"), value = TRUE) txt_contains(x, patterns = c("eats"), value = TRUE) txt_contains(x, patterns = c("^The"), ignore.case = FALSE, value = TRUE) txt_contains(x, patterns = list(include = c("cat"), exclude = c("dog")), value = TRUE) txt_contains(x, "cat") & txt_contains(x, "dog")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.