Try
cumsum(x)
HTH,
Jorge.-
On Sat, Jan 21, 2012 at 6:59 PM, Martin Batholdy <> wrote:
> Hi,
>
>
> I have a somewhat abstract and tricky problem (at least for me).
>
>
> Perhaps someone here can help me:
>
>
> I would like to convert:
>
> x <- c(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0
Perhaps I misunderstand you, but ?cumsum.
x <- c(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0)
y <- c(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4)
identical(cumsum(x), y)
Michael
On Sat, Jan 21, 2012 at 6:59 PM, Martin Batholdy
wrote:
> Hi,
>
>
> I have
Hi,
I have a somewhat abstract and tricky problem (at least for me).
Perhaps someone here can help me:
I would like to convert:
x <- c(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0)
into
x <- c(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4)
every 1 i
3 matches
Mail list logo