Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Filter drop down list based on checkboxinput option

my objective is to filter Country options based on the LMIC column value. Where if(population$LMIC == 'YES') I would like the Countries that have ‘YES’ value to be displayed in the drop down. else(population$LMIC == 'NO') then I would like the Countries that ‘NO’ value to be displayed in the drop down.
Here is my xlsx file

This is currently what I have for my UI.

div(
                                    id = "dashboard",
                                    pickerInput(
                                        inputId = "selectedCountry",
                                        labelMandatory ("Country"), 
                                        choices = population$Country,
                                        multiple = FALSE,
                                        selected = "Czech Republic", #character(0),# 
                                        options = pickerOptions(
                                            actionsBox = TRUE,
                                            title = "Please select a country")
                                    ),
                                    
                                    checkboxInput(inputId = "filterLMIC", label = strong("Filter LMIC"), value = FALSE),

This is currently what I have for my server,

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

observeEvent(input$filterLMIC,{
      if(filterLMIC == TRUE){
          updatePickerInput(session, inputId='selectedCountry',
                            choices = population$LMIC,
                            choicesOpt = list(
                              if(population$LMIC == 'YES'){
                                disable
                              }
                            )
                        
                            )
        
      }
    })

I’m not sure where to go from here.

>Solution :

Try this

observeEvent(input$filterLMIC,{
   if (input$filterLMIC) value <- 'YES' else value <- 'NO'
   population <- population[population$LMIC == value,]
   updatePickerInput(session, inputId='selectedCountry', choices = population$Country)
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading