#' Compute evolution of borrowed capital over a month.
#'
#' @param rate
#' @param transfer
#' @param capital
#' @return
loanStep <- function(rate,
transfer,
capital)
{
interest <- rate * capital
if (interest > transfer)
{
stop("Monthly repay inferior to interest.")
}
capPaid <- min(capital,
transfer - interest) # test if the current payment is enough to end the capital repay
# remCap <- capital - capPaid # remaining capital at the end of the period, ie money that can not be invested
return (list(capPaid = capPaid,
interest = interest))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.