I'm trying to find a way to check whether a list contains an element that itself contains a particular string. Finding an exact match is simple with %in%
:
list1 <- list("a","b","c")
"a" %in% list1
[1] TRUE
But it only works if the element is identical, i.e. it doesn't return TRUE if the element only contains the string:
list2 <- list("a,b","c,d")
"a" %in% list2
[2] FALSE
Is there a way to generate TRUE for the second example? Thanks in advance.