On Tue, Sep 27, 2011 at 6:15 PM, Jean V Adams <jvad...@usgs.gov> wrote:

> For example,
>
> songs <- c("ABCABAABABABCAB", "ABACAB", "ABABCABCBC")
> counts <- gregexpr("ABC", songs)
> sapply(counts, length)

 That will still return '1' for the case where its not found, because of the -1.

sapply(counts,function(x){sum(x>0)})

 will return 0.

 you might get faster performance if you do 'fixed=TRUE' on the
gregexpr call as well.

> P.S.  1981 Genesis album!

 +1 bonus.

Barry

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to