Compound Interest Calculator

Slidify + Shiny

Ashwini
Programmer

This is application is devloped as part of the DataScience project.

How Compond Interest is calculated

 The formula for annual compound interest is A = P (1 + r/n) ^ nt
Where:
  A = the future value of the investment/loan, including interest
  P = the principal investment amount  (the initial deposit or loan amount)
  r = the annual interest rate (decimal)
  n = the number of times that interest is compounded per year
  t = the number of years the money is invested"

ui.r

library(shiny)
shinyUI(fluidPage(
  titlePanel(title="Compound Interest Calculator"),
  sidebarLayout(
    sidebarPanel(
      selectInput("dataset", "CURRENCY:", choices = c( "EURO(€)","GBP(£)","INR(₹)", 
                                                       "USD($)")),
      numericInput("principal", "Principal Amount:", 0, min =0),
      numericInput("rate","Interest Rate in %:",0,min =0),
      numericInput("period","Period:",0,min =0),
      selectInput("freq","Interest paid frequency:",list("Yearly" = 1,
                  "Half Yearly" = "2", "Quarterly"="3","Monthly" = 12)),
      (submitButton("Calculate"))),
    mainPanel(
      tabsetPanel(
        type = "tab",tabPanel("Summary", verbatimTextOutput("Summary")),
        tabPanel("AboutCalculator", verbatimTextOutput("AboutCalculator"))
      ))))
  )

<!--html_preserve-->

Compound Interest Calculator

<!--/html_preserve-->

server.r page 1

shinyServer(
  function(input,output){
   effectiveRate <- reactive({
     round((((1 + (input$rate*0.01)/as.numeric(input$freq))^as.numeric(input$freq))-1)*100,2)
   })
    MaturityAmount <- reactive( round((input$principal * (1 +(input$rate*0.01)/as.numeric(input$freq))^(as.numeric(input$freq) *input$period )),2) )
    output$Summary <- renderText({
      paste(sep = "",
"Base amount: ", input$principal, "\n","Interest Rate: ", input$rate, "\n",
"Effective Annual Rate in %: ",effectiveRate() , "\n",
"Calculation period in Year(s): ",input$period,"\n",
"Interest Earned :", MaturityAmount() - input$principal,     "\n",
"Maturity Amount : ", MaturityAmount() ,"\n"
      )})
})

server.r page 2

    output$AboutCalculator <- renderText({
      paste(sep = "",
"This is application is devloped as part of the DataScience project.

The formula for annual compound interest is A = P (1 + r/n) ^ nt:

  Where:

  A = the future value of the investment/loan, including interest
  P = the principal investment amount  (the initial deposit or loan amount)
  r = the annual interest rate (decimal)
  n = the number of times that interest is compounded per year
  t = the number of years the money is invested"

      )

      }
)