R/payment.R

#' @title An exact formula for the monthly repayment
#'
#' @description
#' source: https://en.wikipedia.org/wiki/Compound_interest
#'
#' @param p is the principal.
#' @param r is the per annum interest rate (as percent e.g. 4.5).
#' @param n is the number of payment periods.
#'
#' @return Monthly epayment.
#'
#' @examples
#' payment(150000, 4.5, 360)
#'
#' @export
payment <- function(p, r, n) {
  r <- r / 100 / 12
  (p * r) / (1 - exp(-n * log(1 + r)))
}
pgstevenson/borrowr documentation built on May 15, 2019, 10:02 p.m.