Re: [R] Summarization

2010-04-14 Thread Pete B
Dennis Very nice! Thanks Pete -- View this message in context: http://n4.nabble.com/Summarization-tp1840718p1840730.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/lis

Re: [R] Summarization

2010-04-14 Thread Dennis Murphy
Hi: Try this: with(rle(x), data.frame(Level = values, Count = lengths)) Level Count 1 1 3 2 0 4 3 1 2 4 0 3 5 1 2 6 0 1 HTH, Dennis On Wed, Apr 14, 2010 at 7:11 PM, Pete B wrote: > > Hi All > > I have a vector x containing 2 levels > > x = c(1

[R] Summarization

2010-04-14 Thread Pete B
Hi All I have a vector x containing 2 levels x = c(1,1,1,0,0,0,0,1,1,0,0,0,1,1,0) I would like to derive the following summarization Level Count 1 3 0 4 1 2 0 3 1 2 0 1 I have generated an inelegant solution using lags and loops but feel sure that there must be a better approach. If anyone ha