[R] detect subset in series

threshold r.kozarski at gmail.com
Wed Nov 16 16:10:13 CET 2011


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.



More information about the R-help mailing list