#' Calculate monthly payment
#'
#' Calculate payment based on APR, Amount Financed and Term (in months).
#' Should yield same results as Excel's "PMT" function
#'
#' @param r A float number representing APR.
#' @param p A float number representing amount financed
#' @param n An integer representing term in months
#'
#' @return A float number representing monthly payment
#' @export
#'
#' @examples
#' alf_payment <- pmt(0.17, 30000, 72)
pmt <- function(r, p, n){
rate <- r / 12
cumu <- (1 + rate) ^ n
return( p * ( (rate * cumu) / (cumu - 1) ) )
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.