other/01_main.R

# Development of BorrowR functions/scripts/etc.
# Created by Paul Stevenson 12-July-2018

library(tidyverse)
library(lubridate)
library(RJSONIO)

# helper functions
source("other/02_helper.R")

# import data
data <- fromJSON("data/00001.json") %>% format_data()

# plot of accumulated principle
ggplot(data = data.frame(x = 0), mapping = aes(x = x)) +
  stat_function(fun = accumulation_function, args = c(4.5, 4)) +
  xlim(0, 30)

# monthly repayment
payment(data$loan_amount, tail(data$rates, 1)$rate, data$duration_years * 12)
periodic_compounding(data$loan_amount, tail(data$rates, 1)$rate, 12, data$duration_years)

payment(450000, 4.5, 360)
amrt <- amortize(150000, 760.028, 4.5, 360)
summary(amrt)
plot(amrt)

amrt %>%
  select(month, balance, principal, interest, paid) %>%
  tbl_df()

amrt[c("month", "balance", "principal", "interest", "paid")] %>% tbl_df()
pgstevenson/borrowr documentation built on May 15, 2019, 10:02 p.m.