Shiny Currency Converter app

Ivan Marchenko
Sun Mar 22

App making motivation

  • I think about app which get some dynamically changed data from web.
  • Currency rates very interested information fo financiers and travelers.
  • Ukrainian Hrivna (UAH) is one of the most devaluated currency in the world last year.

ui.R

shinyUI(pageWithSidebar(
    titlePanel("Currency conversion application"),
    ## Sidebar
    sidebarPanel(helpText(p(h5("This application converts the selected currency based on your inputs."))),            
       br(),  selectInput("from", "From:", c("USD","UAH","EUR"), selected= "USD"),
       br(),  selectInput("to", "To:", c("USD","UAH","EUR"), selected = "EUR"),
       br(),  numericInput("sum", label = p(h5("Choose the sum you want to convert")), value = 100),
    ## MainPanel
        mainPanel(
                tabsetPanel(tabPanel("Output",
                                 p(h3("You exchange:")),
                                 textOutput("sum"),
                                 p(h3("You get:")), 
                                 tableOutput("converted")  ),))))

Server.R calculations Code

Code which make calculations is wery simply:

rate <- read.csv(paste0(
    "http://quote.yahoo.com/d/quotes.csv?s=", 
     input$from, input$to, "=X&f=sl1&e=.csv"), header = FALSE)

converted <- paste((input$sum*rate$V2), input$to)

Currency rate gets as json object from API. And after it multiplies by inputted sum.

Links