samedi 30 juillet 2016

checkbox not selected in a shiny app

I need to prepare a shiny app for a school project. This is a link of what it is supposed to look like

http://ift.tt/2am3byr

If you look at the app you see there is a checkbox named medals.When you open the app they are all selected but in the event the user decides to uncheck them all there should be a small error and no graph should be drawn.

I am having trouble getting to this, when I uncheck all the boxes in my app it draws an empty drawing

This is the important part of the code:

 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)

I am using a function plot.medals2 that gets a vector of medals ,start year, ending year, country and returns a drawing of the graph.




Aucun commentaire:

Enregistrer un commentaire