Yearly Compound Interest Calculator

Alex Pouletsos
March 18, 2018

Overview

Yearly Compound Interest is the interest earned on both the principal amount plus the accrued interest from prior years.

Formula: I = P(1 + r)y - P

I = Accrued Interest
P = Principal
r = Interest Rate
y = Number of years

Example

Suppose you put a deposit of $5,000 into a savings account with 5% interest. You will have earned $3144.47 at the end of 10 years.

P <- 5000
r <- .05
df <- NULL
for (i in 1:50) {
        P <- round(P*(1+r),2)
        df <- rbind(df, P-5000)
}
df <- as.data.frame(df)
df <- cbind(1:50, df)
names(df) <- c("Year", "Interest Earned")
df[1:10,]
   Year Interest Earned
1     1          250.00
2     2          512.50
3     3          788.12
4     4         1077.53
5     5         1381.41
6     6         1700.48
7     7         2035.50
8     8         2387.28
9     9         2756.64
10   10         3144.47

Example Plot

plot(df)
points(10, round(5000*(1+.05)^10, digits=2)-5000, col = "red", pch = 16, cex = 1.75)

plot of chunk unnamed-chunk-2

Notice the exponential curve of the graph due to the compounding interest.

Compound Interest Calculator Shiny App

With this Shiny Application, you can input any principal amount and interest rate and see what the accrued interest will be for each year.

  • Input your initial loan or savings amount in the “Principal” box.
  • Input the interest rate in the “Interest Rate” box. (e.g. Enter .05 for a 5% interest rate)
  • Use the slider to see how much interest is accrued at the end of a given year.

Link to application https://alexpouletsos.shinyapps.io/shiny_application/

Link to ui.R & server.R files used to produce Shiny App https://github.com/AlexPouletsos/Comp_Int_Calc_Shiny