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

______________________________________________
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