Function to create an amortization fund table in R

January 3, 2017

(This article was first published on Data R Value, and kindly contributed to R-bloggers)

Function to create an amortization fund table.
We establish the precision with which we want to work

options(digits = 7)

we say we do not want to work in scientific notation

options(scipen = 999)

We declare vectors to store the values of the different variables

I <- numeric();CA <<- numeric();SF <<- numeric()

We give values for the amount, number of periods and interest rate
M <- 2400000
n <- 50
i <- 3.7/100

We create function:

f.amort <- function(M,i,n) {
  R <<- M*i/(((1 + i)**n)-1)
  I[1] <<- 0
  I[2] <<- R*i
  CA[1] <<- R
  SF[1] <<- R
  for (k in 1:(n-1)) { 
    CA[k+1] <<- R + I[k+1]
    SF[k+1] <<- SF[k] + CA[k+1]
    if (k < n-1){
      I[k+2] <<- SF[k+1]*i 

f.amort(M, i, n)

tabla <- cbind(I,CA,SF)
rtotal <- R*n
totales <- c(rtotal,sum(I),sum(CA),000)
renta <- c(R, recursive=TRUE)

tabla <- cbind(renta, tabla)
tabla <- rbind(tabla, totales)
colnames(tabla) <- c(“Rent”,”Interest”,”
Accumulated Amount“, “Closing Balance“)

You can get the script in:

To leave a comment for the author, please follow the link and comment on their blog: Data R Value. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)