From: Keith Jones <keithlj_at_suddenlink.net>

Date: Sat, 5 Jan 2008 08:32:41 -0600

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 06 Jan 2008 - 14:46:05 GMT

Date: Sat, 5 Jan 2008 08:32:41 -0600

Hi,

Maybe I have not been looking in the right spot, but, I have not been able to fine a command to automatically calculate the running cumulative sum of a vector. Is there such a command?

Example of current code:

> eig$values

[1] 678.365651 6.769697 2.853783

> prop<-eig$values/sum(eig$values)

*> prop
*

[1] 0.986012163 0.009839832 0.004148005

> cum<-c(prop[1],sum(prop[1:2]),sum(prop[1:3]))

*> cum
*

[1] 0.9860122 0.9958520 1.0000000

This works, but, if the length of the vector changes I have to manually change the code.

Thanks,

Keith Jones

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 06 Jan 2008 - 14:46:05 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sun 06 Jan 2008 - 15:30:05 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*