[R] count sequence of integers

2007-02-15 Thread Samuel Kemp
Hi, I would like to be able to count a sequence of numbers. For example, given a vector of the following integers (1,1,1,2,2,2,2,3,3,3,3,3,3,1,1,1,1, 3,3) the function would return (3, 4, 6, 4,2) Does anyone have any cool ideas to solve this? Any help appreciated. Regards, Sam.

Re: [R] count sequence of integers

2007-02-15 Thread Roger Bivand
On Thu, 15 Feb 2007, Samuel Kemp wrote: Hi, I would like to be able to count a sequence of numbers. For example, given a vector of the following integers (1,1,1,2,2,2,2,3,3,3,3,3,3,1,1,1,1, 3,3) the function would return (3, 4, 6, 4,2) ?rle x -

Re: [R] count sequence of integers

2007-02-15 Thread Martin Becker
Samuel Kemp wrote: Hi, I would like to be able to count a sequence of numbers. For example, given a vector of the following integers (1,1,1,2,2,2,2,3,3,3,3,3,3,1,1,1,1, 3,3) the function would return (3, 4, 6, 4,2) Does anyone have any cool ideas to solve this? Maybe not the most

Re: [R] count sequence of integers [Broadcast]

2007-02-15 Thread Wiener, Matthew
] count sequence of integers [Broadcast] Samuel Kemp wrote: Hi, I would like to be able to count a sequence of numbers. For example, given a vector of the following integers (1,1,1,2,2,2,2,3,3,3,3,3,3,1,1,1,1, 3,3) the function would return (3, 4, 6, 4,2) Does anyone have any cool ideas