How to Check if string contains certain characters in R
To check if a string contains certain characters or not, we can use the grepl() function in R language.
Here is an example that checks the ll characters in the Hello string.
str <- "Hello"
chars <- "ll"
grepl(chars, str, fixed = TRUE)Output:
> grepl(chars, str, fixed = TRUE)
[1] TRUEFalse case
str <- "Hello"
chars <- "es"
grepl(chars, str, fixed = TRUE)Output:
> grepl(chars, str, fixed = TRUE)
[1] FALSE

