I am trying to find the index of a list for which one element matches a specific pattern and has n characters>1, for example:
i = "a"
ll = list(c("a"), c("b", "abc"), c("cc", "b"), c("c", "b"), c("ac", "c"), c("a", "bc"))
I would like to extract ll[[2]] and ll[[5]]. This kind of gets me to the right path, but not quite because I only want the elements that contain the pattern and have nchar>1...
sapply(ll, function(x) sapply(x, function(x) nchar(x)>1 & grep(i, x)))
Thank you!!