[R] Count matches of a sequence in a vector?

mieke hcS_ffetS at gmx.de
Wed Apr 21 16:16:10 CEST 2010


Hey there,

I need to count the matches of a sequence seq=c(2,3,4) in a long vector
v=c(4,2,5,8,9,2,3,5,6,1,7,2,3,4,5,....).
With sum(v %in% seq) I only get the sum of sum(v %in% 2), sum(v %in% 3) and
sum(v %in% 4), but that's not what I need :(

Who can help me?
Thanks a lot!
-- 
View this message in context: http://n4.nabble.com/Count-matches-of-a-sequence-in-a-vector-tp2019018p2019018.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list