Dear Helpers:
 
I spend more than half a day to solve this problem in R:
 
Let x be a vector of a string of 0s and 1s, such as 
x<-c(0,0,1,1,0,0,0,0,1,1,0,0,0,0). It can be a very long vector.
How to sub vectors of 0s? In the above example, I would like get the vectors (0,0), (0,0,0,0), (0,0,0,0). 
I can use which(x==0) to get the index of the 0 elements, but I don't know how to get the starting indices and end indices of the subvectors. Maybe we should use which(x==1), but I don't know how.
 
Thanks.
 
Bob


      
	[[alternative HTML version deleted]]

