Dear R-users,

Say that I have a sequence of zeroes and ones:

x <- c(1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0)

The sequences of ones represent segments and I want to report the starting and endpoints of these segments. For example, in 'x', the first segment starts at location 1 and ends at 3, and the second segment starts at location 8 and ends at location 10. Is there an efficient way of doing this in R without having to right a bunch of if-else conditions? I know the rle function will report the length of the segments but not the endpoints.

Thanks in advance.

Gregory Gentlemen



      __________________________________________________________________
[[elided Yahoo spam]]


	[[alternative HTML version deleted]]

