Re: [R] how to count number of occurrences

2011-11-04 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of uka > Sent: Thursday, November 03, 2011 4:10 PM > To: r-help@r-project.org > Subject: Re: [R] how to count number of occurrences > > This was very help

Re: [R] how to count number of occurrences

2011-11-03 Thread uka
This was very helpful. Thank you very much. Just one question, I notice that it does not count the number of X's before the first Y. I want the result be 1 4 0 0 0 5 0 0 0 0. I tried combining this output with the first value of rle output, but realized that rle doesn't give me the 0s. So, if my fi

Re: [R] how to count number of occurrences

2011-11-02 Thread Sarah Goslee
Hi, On Wed, Nov 2, 2011 at 12:54 PM, Sl K wrote: > Dear R users, > > I have this data frame, >           y samp > 8 0.03060419    X > 18 0.06120838    Y > 10 0.23588374    X > 3 0.32809965    X > 1  0.36007100    X > 7 0.36730571    X > 20 0.47176748    Y > 13 0.65619929    Y > 11 0.72014201    

Re: [R] how to count number of occurrences

2011-11-02 Thread David Winsemius
On Nov 2, 2011, at 12:54 PM, Sl K wrote: Dear R users, I have this data frame, y samp 8 0.03060419X 18 0.06120838Y 10 0.23588374X 3 0.32809965X 1 0.36007100X 7 0.36730571X 20 0.47176748Y 13 0.65619929Y 11 0.72014201Y 17 0.73461142Y 6 0.762

Re: [R] how to count number of occurrences

2011-11-02 Thread William Dunlap
;X", "X", "X", "X", "X", "Y", "Y", "Y", "Y", "Y") > diff((seq_along(samp) - cumsum(samp=="Y"))[samp=="Y"]) [1] 4 0 0 0 5 0 0 0 0 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com

[R] how to count number of occurrences

2011-11-02 Thread Sl K
Dear R users, I have this data frame, y samp 8 0.03060419X 18 0.06120838Y 10 0.23588374X 3 0.32809965X 1 0.36007100X 7 0.36730571X 20 0.47176748Y 13 0.65619929Y 11 0.72014201Y 17 0.73461142Y 6 0.76221313X 2 0.77005691X 4 0.92477243