Help with Filtering Data Based on Input of Nested SelectInputs

Hello Everyone,
I would love to have some help with this issue I am running into while creating a Shiny Dashboard.
Currently I have a subject filtering system in the UI that works like this:

There is one main selectInput (filter A) with options = 1,2,3,4
if option 1 is selected, nothing should happen (this will be for an overview of the data means)
if option 2 is selected, another selectInput will appear (filter B) with its own set of choices
if option 3 is selected, another selectInput will appear (filter C) with its own set of choices
if option 4 is selected, another selectInput will appear (filter D) with its own set of choices

Currently I have this working well in the UI. However, in the server I need to filter (I am using dplyr) the data based on either Filter A (if option 1 is picked), or one of the options within Filter B,C, or D (depending on which one is selected) to create a ggplot.

I am new to R and firstly don't have a great idea of how to do this. Secondly, I also run into the problem that for instance if a choice from Filter B is selected, Filter C and D will have no inputs and I get an error saying that a value of 0 can't be put through the filter system.

I really hope someone can help out with this! Thanks so much!
I look forward to chatting.

Here is some more information:

UI:
ui <- dashboardPage(
dashboardBody(

selectInput( "Category", "Select Category", c("Overview", "Position", "Age", "Player")),
uiOutput('outputfilter'))
))

Server:
server <- function(session, input, output) {

observeEvent(input$Category,{
    categoryfilterinput<- paste(input$Category)
    output$outputfilter <- renderUI({
        switch(categoryfilterinput,
                  "Position" = selectInput('positioninput', 'Select Position', choices = c("Forwards","Defencemen", "Goalies")),
                  "Age" = selectInput('ageinput', 'Select Age Range', choices = c("<20","20-23", "23-25", "25-30", ">30")),
                  "Player" = selectInput("Playernameinput", "Select Player", choices = Roster$Playername))

})
})

Also, it is important to note that there are quite a few "NA"s in my data set. I unfortunately can not replace these with zeros so I must deal with them. which in this particular case has turned out to be challenging

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.