Skip to content
Prev 139877 / 398525 Next

running balance down a dataframe referring back to previous row

Try:

 cs <- with(txns,cumsum(cr - dr))

You could if needed adjust the starting value to zero by concatenating a
zero in front and dropping the last entry.

txns$running.bal <- c(0,cs[seq(length(cs) - 1)])

Good luck.
seanpor wrote: