to check if a string contains a given element we can do
strings <- c("4|x|4", "4x4", "1|x|1")
element <- "4"
grepl(element, strings)
#[1] TRUE TRUE FALSE
but if the element is a |
this no longer works.
grepl("|", strings)
#[1] TRUE TRUE TRUE
How can we return TRUE
,FALSE
,TRUE
?