R/periodic_compounding.R

#' @title The total accumulated value, including the principal sum plus compounded interest
#'
#' @description
#' source: https://en.wikipedia.org/wiki/Compound_interest
#'
#' @param p is the original principal sum.
#' @param r is the nominal annual interest rate (as percent e.g. 4.5).
#' @param n is the compounding frequency.
#' @param t is the overall length of time the interest is applied (expressed using the same time units as r, usually years).
#'
#' @return The new principle sum.
#'
#' @examples
#' periodic_compounding(1500, 0.043, 4, 6)
#'
#' @export
periodic_compounding <- function(p, r, n, t) {
  r <- r / 100
  p * (1 + r / n)^(n * t)
}
pgstevenson/borrowr documentation built on May 15, 2019, 10:02 p.m.