Displaying 1 result from an estimated 1 matches for "drcr".
Did you mean:
dcr
2008 Mar 19
1
running balance down a dataframe referring back to previous row
...balance. This is easy to write in a loop, but I can't seem to get
it working in vectorised code. Hopefully the example below will explain
what I'm trying to do...
#####
# create a dummy dataframe
txns <- data.frame(LETTERS)
set.seed(123)
# randomly specify debit / credit columns
txns$drcr <- sample(c('d','c'), nrow(txns), replace=T)
txns$dr <- 0
txns$cr <- 0
# give values to the debits / credits...
txns[txns$drcr == 'd', 'dr'] <- runif(nrow(txns[txns$drcr == 'd',]), min=0,
max=10000)
txns[txns$drcr == 'c', 'cr'] &l...