Skip to content

Instantly share code, notes, and snippets.

@ivaninkv
Last active December 28, 2016 18:13
Show Gist options
  • Save ivaninkv/05efe9d6c0b83a10650a10b03dc5a6ed to your computer and use it in GitHub Desktop.
Save ivaninkv/05efe9d6c0b83a10650a10b03dc5a6ed to your computer and use it in GitHub Desktop.
rm(list = ls())
gc()
library(data.table)
pct <- 14.57 / 100 / 365
day <- 21
dt <- expand.grid(base = seq(1000, 100000, 0.01), rate = c(1/2, 3/5, 3/8, 5/8, 7/11))
setDT(dt)
dt[, child1 := round(base * rate, 2)]
dt[, child2 := base - child1]
dt[, add.paym := round(base * pct * day, 2)]
dt[, add.paym1 := round(child1 * pct * day, 2)]
dt[, add.paym2 := round(child2 * pct * day, 2)]
dt[, diff := round(add.paym - add.paym1 - add.paym2, 2)]
unique(dt$diff)
res <- dt[abs(diff) > 0]
fwrite(res[sample(nrow(res), 1000)], 'add.payment.csv', sep = ';')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment