Hi currently I've got a sample data set like this
df<- data.frame(site = c('A1', 'A1', 'A1', 'B1', 'B1','B1','B1','C1','C1'),
part = c('a1', 'a1', 'a2', 'b1', 'b1', 'b2','b3','c1','c2'),
value = c(2,3,4,5,6,7,8,9,10))
> df
site part value
A1 a1 2
A1 a1 3
A1 a2 4
B1 b1 5
B1 b1 6
B1 b2 7
B1 b3 8
C1 c1 9
C1 c2 10
I would like to put a side bar in shiny user interface with two select boxes. One is "choose" site and the other one is "part".
shinyUI(
fluidPage(
titlePanel("Choose Site, part"),
sidebarLayout(
sidebarPanel(
selectInput("select_site", label = "Select Site",
choices = unique(df$site),
selected = unique(df$site)[1]),
selectInput("select_part", label = "Select Part",
choices = unique(df$part),
selected = unique(df$part)[1])
),
mainPanel(
plotOutput("example")
)
)
)
)
The objective is when I choose A1 in "select_site", I can only choose a1 or a2 in "select_part". However this code right now can choose a1, a2, b1, b2, b3, c1, c2 in "select_part" no matter how I choose in "select_site".
In the real data set there are a lot more sites and parts than this example so I'm looking for a generic way to identify the parts within each site rather than type in the names myself.
Can anyone help me with some modification of this code?
Thanks in advance