Ivan Marchenko
Sun Mar 22
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") ),))))
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.
The link to the App is: http://chemarch.shinyapps.io/ShinyCurrencyConverter/
This presentation: http://rpubs.com/Chemarch/CurrencyConverter
Original converter by Yahoo!: http://finance.yahoo.com/currency-converter/#from=USD;to=EUR;amt=100