str_detect2 | R Documentation |
Vectorised over string
and pattern
.
Actually equivalent to grepl(pattern, x)
as returns FALSE
for NA
s (unlike stringr::str_detect()
).
This behavior is useful when searching comments many of which are NA to
indicate no comments present.
str_detect2(string, pattern, negate = FALSE)
string |
Input vector. Either a character vector, or something coercible to one. |
pattern |
Pattern to look for. The default interpretation is a regular expression, as described in
Match a fixed string (i.e. by comparing only bytes), using
Match character, word, line and sentence boundaries with
|
negate |
If |
A logical vector the same length as string
/pattern
.
grepl()
and stringr::str_detect()
x <- c("b", NA, "ab")
pattern <- "^a"
grepl(pattern, x)
stringr::str_detect(x, pattern)
str_detect2(x, pattern)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.