I've the following vector. It is a large vector but for the purpose of illustration I'll keep it short.
x = c(1,1,1,1,0,0,0,0,1,1,0,0,0,1,1)
Notice that the 1's come in chunks within the vector. In this case there is a chunk of four 1s two chunks of two 1's. How do I find this distribution in an easy and efficient manner? Expected output is
chunk.length freq 4 1 2 2
Thanks much in advance.