Thanks for the answer. I found that smth like below works

subset <- c(1,0,0)
series <- c(1,1,1,0,1,0,0,1,1,0,0,0,0,1)

subset1 <- paste(subset, collapse='')
series1 <- paste(series, collapse='')

xx <- gregexpr(subset1, series1, fixed=TRUE)
as.numeric(xx[[1]]) ## yields the first element numbers in series
[1] 5 9

--
View this message in context: 
http://r.789695.n4.nabble.com/detect-subset-in-series-tp4076285p4076644.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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