[R] count zero or one in a list

2008-10-24 Thread gallon li
I have a list of {0,1} values, say y-c(0,0,0,1,1,0,0,1,0,1,1,1,1) I want to compute the first few zeros and the last few ones. So the output I expect is 3 and 4 for this vector. Is there a fast way to match the numbers easily? [[alternative HTML version deleted]]

Re: [R] count zero or one in a list

2008-10-24 Thread Henrique Dallazuanna
Try this: rle(y)$len[c(1, length(rle(y)$len))] On Fri, Oct 24, 2008 at 10:34 AM, gallon li [EMAIL PROTECTED] wrote: I have a list of {0,1} values, say y-c(0,0,0,1,1,0,0,1,0,1,1,1,1) I want to compute the first few zeros and the last few ones. So the output I expect is 3 and 4 for this