Glad it worked! The one "gotcha" is that it does not handle missing
values, so for example:
> cumsum(c(1, 2, 3, NA, 4))
[1] 1 3 6 NA NA
both the NA, and everything after it become NA (missing). If you find
yourself working with tables and frequencies and the like, you may
also like (if you h
>From: Joshua Wiley
>dat$RTotal <- cumsum(dat$BAL)
Wow, that's really great. I'm starting to really enjoy using R. My statistical
needs are not that great, but I love the way that R handles tabular data.
__
R-help@r-project.org mailing list
https
Hi Mark,
Take a look at ?cumsum and see if this is what you want:
## your data output via dput() (easy to copy and paste from email to R)
dat <- structure(list(ACC = c("hal", "opn", "pga", "prt", "rbs"),
BAL = c(-171245.33,
-50487.63, 213440.38, 0.18, 8292.54)), .Names = c("ACC", "BAL"
), class =
Table is not a regular data structure in R so I can't help further without a
bit of clarification, but try ?cumsum and ?cbind.
Michael
On Nov 13, 2011, at 4:18 PM, Mark Carter wrote:
> I have a table which looks like this:
>
> � ACC��� BAL
> 1 hal -171245.33
> 2 opn� -50487.63
> 3 pga�
I have a table which looks like this:
ACC BAL
1 hal -171245.33
2 opn -50487.63
3 pga 213440.38
4 prt 0.18
5 rbs 8292.54
How do I create a column which shows the running totals of the BAL columns?
[[alternative HTML version deleted]]
__
First of all, this is not a list, this is a vector. Second, see ?cumsum.
Best,
Gabor
On Mon, Feb 9, 2009 at 11:13 PM, glenn wrote:
>very simple question I am sure sorry:
>
>
>
> for a list;
>
>
>
> test <-c(1,2,3)
>
>
>
> how do I total them up please to return the result
>
>
>
>
>
>
very simple question I am sure sorry:
for a list;
test <-c(1,2,3)
how do I total them up please to return the result
1,3,6
Regards
Glenn
[[alternative HTML version deleted]]
__
R-help@r-project.or
7 matches
Mail list logo