[R] Decreasing Cumsum Function?

Rolf Turner r.turner at auckland.ac.nz
Tue Mar 23 02:14:14 CET 2010


On 23/03/2010, at 2:02 PM, Gundala Viswanath wrote:

> Hi all,
> 
> I have a frequency data that looks like this.
> 
> 3
> 2
> 1
> 5
> 
> What I want to get is the "decreasing" cumulative of this data
> yielding
> 
> 11
> 8
> 6
> 5
> 0
> 
> Is there any?
> 
> I am aware of cumsum(), which will yield
> 3
> 5
> 6
> 11.
> 
> But it is not what I want.

rev(cumsum(rev(c(x,0))))
[1] 11  8  6  5  0

?rev

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list