Re: [R] Running totals

2011-11-14 Thread Joshua Wiley
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

Re: [R] Running totals

2011-11-14 Thread Mark Carter
>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

Re: [R] Running totals

2011-11-13 Thread Joshua Wiley
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 =

Re: [R] Running totals

2011-11-13 Thread R. Michael Weylandt
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�

[R] Running totals

2011-11-13 Thread Mark Carter
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]] __

Re: [R] running totals in a list

2009-02-09 Thread Gábor Csárdi
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 > > > > > >

[R] running totals in a list

2009-02-09 Thread glenn
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