[R] Finding (Ordered Subvectors)
Lorenzo Isella
lorenzo.isella at gmail.com
Tue Sep 21 12:31:38 CEST 2010
Dear All,
Consider a simple example
a<-c(1,4,3,0,4,5,6,9,3,4)
b<-c(0,4,5)
c<-c(5,4,0)
I would like to be able to tell whether a sequence is contained (the
order of the elements does matter) in another one e.g. in the example
above, b is a subsequence of a, whereas c is not. Since the order
matters, I cannot treat the sequences above as sets (also, elements are
repeated).
Does anyone know a smart way of achieving that?
Many thanks
Lorenzo
More information about the R-help
mailing list