I need to create a shiny app for a school project this is a link of how it is supposed to look like:
Now if you look there is a checkbox named medals and the user needs to select which medals he wants to be plotted. When the user does not select anything (when you first enter the app they are all selected so he needs to uncheck) there needs to be a small red error message saying year 'not found. I don't know how to turn the shiny app to a website so I can't attach what I get but basically instead of getting an error message I get an empty plot. This is the code
library(shiny)
library(ggplot2)
library(dplyr)
library(reshape)
source('helpers.R')
ui<-shinyUI(fluidPage(
titlePanel("The R Olympic Medal Viewer"),
fluidRow(column(3,
selectInput("country", label = strong("Country"),
choices = list("Australia"='AUS', "China" = 'CHN',
" Spain" = 'ESP','France'='FRA','United Kingdom'='GBR','Germany'='GER',
'South korea'='KOR','Netherlands'='NED','Russia'='RUS','United states'='USA'), selected = 1))),
fluidRow(column(3,
sliderInput("Startingyear", label = strong("Starting year"),
min = 1896, max = 2008,value = 1896 )
)),
fluidRow(column(3,
sliderInput("Endingyear", label = strong("Ending year"),
min = 1896, max = 2008,value = 2008 )
)
),
fluidRow(
column(3,checkboxGroupInput("Medals", label = strong("Medals"),
choices = list("Total" = "TOTAL", "Gold" = 'GOLD',
"Silver" = 'SILVER','Bronze'='BRONZE'),
selected = c('TOTAL','GOLD','SILVER','BRONZE')))),
fluidRow(
mainPanel(plotOutput('coolplot'),width = '40%'))
)
)
server <- function(input, output){output$coolplot<-renderPlot(plot.medals2(input$country,
input$Startingyear,input$Endingyear,input$Medals))}
shinyApp(ui = ui, server = server)
What can I do to get it to be similar to what is on the website?
Aucun commentaire:
Enregistrer un commentaire