Minimum reproducible example:
#### global.R
combinations <- data.frame(animal = c(rep('cat', 2),
rep('dog', 3),
rep('horse', 2)),
color = c('blue',
'black',
'red',
'red',
'black',
'red',
'green'),
region = c('west',
'west',
'east',
'west',
'east',
'west',
'east'))
Basically, I want to offer an UI option on a shiny app to first choose your animal, and THEN have a 'color' drop-down pop out using only possible values for the animal selected. THEn a 'region' drop-down should pop out under and contain only acceptable values based on the other two.
I did a very basic version but am having trouble how to nest this.
#### ui.R
library(shiny)
shinyUI(fluidPage(
# Sidebar with dropdown for animal
sidebarLayout(
sidebarPanel(
selectInput("animal",
label = "Choose your animal:",
choices = unique(combinations$animal)) ,
wellPanel(uiOutput("ui_1")),
)
)
))
Is there a way to avoid manually typing out every possible combination and wrapping it in a 'uiOutput' call? The real file I'm using has approximately 1200 possible combinations.