I have two selectInput
s, and I would like the selection in the first one (Brand) to change the possible selections in the second one (Candy). So, for example, if someone chose "Nestle" in the first input box, then only Nestle candy bars will show up in the second box. My data table has a column for Brand and a column for Candy bar type.
I have the following code to start, but this shows ALL of the choices, regardless of the selection.
selectInput(inputId="brand",
label="Brand:",
choices=as.character
(unique(candyData$Brand)),
selected = "Nestle"
),
selectInput(inputId="candy",
label="Candy:",
choices=as.character
(unique(candyData$Candy)),
selected = "100Grand"
The dataset looks like the following:
Brand Candy
Nestle 100Grand
Netle Butterfinger
Nestle Crunch
Hershey's KitKat
Hershey's Reeses
Hershey's Mounds
Mars Snickers
Mars Twix
Mars M&Ms
Updated Question
How do I update the ValueBox in my Dashboard based on the subsequent filtering?
output$count <- renderValueBox({
valueBox(
value = nrow(candyData),
subtitle = "Number of Candy Bars",
icon = icon("table")
)
})
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…