I used grepl to check if a string contains any pattern from a set of patterns (I used '|' to separate patterns). Reverse search did not help. How to define a set of patterns that match?
Additional information: . This can be solved by writing a loop, but it is very time consuming, since my set has> 100,000 lines. Is it possible to optimize it?
For example: let the line be a <- "Hello"
pattern <- c("ll", "lo", "hl")
pattern1 <- paste(pattern, collapse="|") # "ll|lo|hl"
grepl(a, pattern=pattern1) # returns TRUE
grepl(pattern, pattern=a) # returns FALSE 'n' times - n is 3 here
source
share