[R-SIG-Finance] Sequence ID
martin.becker at mx.uni-saarland.de
Wed Sep 10 17:04:10 CEST 2008
test = c(0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0)
Jorge Nieves wrote:
> First I would like to apologize if this is not the right forum for the
> following question.
> I have the following sequence of ZEROS and ONES. I would like to ID
> each "package" of ONES with a unique identifier.
> test = c(0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0)
> An example could be the following vector
> Where all the consecutive ONES have the same ID. I can create the ID
> using a loop, but I was wondering if anyone could recommend another
> method. I suspect that something in the area of factors might help, but
> I do not know what will be the best approach. Any recommendations will
> be highly appreciated.
> Jorge Nieves
> Phone 212.782.7083
> Fax 212.642.7644
> [[alternative HTML version deleted]]
> R-SIG-Finance at stat.math.ethz.ch mailing list
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
Dr. Martin Becker
Statistics and Econometrics
Campus C3 1, Room 206
More information about the R-SIG-Finance