#' @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)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.