I am trying to count the number of occurrences of a substring inside a character vector. For instance:
lookin<-c("babababa", "bellow", "ra;baba")
searchfor<-"aba"
str_count(lookin, searchfor)
returns: 2 0 1
However, I want it to return “3 0 1”, but it does not rise in the middle of “aba” in the first element, since it is partially used in the first instance (I think).
I found this question , but could not figure out how to use it with a vector that has multiple elements.
source
share