Re: [R] Finding and manipulation clusters of numbers in a sequence of numbers

2012-07-16 Thread William Dunlap
r-help@r-project.org > Subject: [R] Finding and manipulation clusters of numbers in a sequence of > numbers > > Hi, > > I have the following sequence: > in <- c(0, 0, 0, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 0,

Re: [R] Finding and manipulation clusters of numbers in a sequence of numbers

2012-07-16 Thread Gabor Grothendieck
On Mon, Jul 16, 2012 at 12:17 PM, mdvaan wrote: > Hi, > > I have the following sequence: > in <- c(0, 0, 0, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 0, 2, 0, 0, 2) > > >From this sequence I would like to get to the following sequence: > o

[R] Finding and manipulation clusters of numbers in a sequence of numbers

2012-07-16 Thread mdvaan
Hi, I have the following sequence: in <- c(0, 0, 0, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 0, 2, 0, 0, 2) >From this sequence I would like to get to the following sequence: out <- c(0, 0, 0, 3, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1