[R] "stepwise" sum

Sarah Goslee sarah.goslee at gmail.com
Wed Oct 5 21:15:42 CEST 2011


> cumsum(c(2,1,4,5))
[1]  2  3  7 12


On Wed, Oct 5, 2011 at 10:06 AM, behave <dethlef1 at hotmail.com> wrote:
> dear R-Community
>
> is there a function which sums data "stepwise"
>
> exp:
>
> 2
> 1
> 4
> 5
>
> Desired  result
>
> 2 = 2
> 2+1 = 3
> 2+1+4 = 7
> 2+1+4+5 = 12
>
> Is there a built in function for this?
>
> Thx
> Dom
>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list