0

So say, x <- c("aa/bb:cc/dd", "aa/cc:cc/dd", "aa/cc:aa/ee") y <- c("aa")

now I need to count the substring "aa" along the row it should give me the count irrespective if it is present as two times. eg: aa= 3 not 4

R_to_kn
  • 23
  • 4
  • You could use `sum(grepl(y, x))` or `sum(grepl(y, x, fixed=TRUE))` for a bit of a speed boost in this case. – lmo Jun 19 '17 at 19:56
  • Ya its working for this but if I have to identify for multiple things like "aa", "bb" together do we have any option. Mine is in a dataframe as well. – R_to_kn Jun 19 '17 at 20:54
  • You should spend some time learning the basics of regular expressions. It will be worth the effort. I like this site: http://www.regular-expressions.info/. – lmo Jun 20 '17 at 11:31

0 Answers0