[R] detect subset in series
David Winsemius
dwinsemius at comcast.net
Wed Nov 16 15:55:57 CET 2011
On Nov 16, 2011, at 8:25 AM, threshold wrote:
> Dear R Users, I am curious whether there is any simple solution o my
> problem.
>
> My example 'series':
> series <- c(1,1,1,0,1,0,0,1,1,0,0,0,0,1)
>
> My 'subset' of interest:
> subset <- c(0,0,0,0)
>
> Is there any function which tells me that the subset exists in my
> series,
> and gives me position where in series is starts. In provided example
> the
> subset exists and covers the elements 10:13 of the 'series'.
?rle
?cumsum # may be needed to accumulate the number of postions before
the rle$lengths criterion is first met.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list