I would like to tweak my second selectInput(market)
. Note that when choosing Sunday or Tuesday in the calendar, the corresponding work shift appears, which in this case is Morning or Evening. These values are considering information from my df1
database. Therefore, for example, if I choose a Sunday on the calendar, then choose Morning shift, I would like it to show in the second selectInput
the markets that work Sunday Morning, which in this case would be Market1 and Market2.
library(shiny)
library(shinythemes)
library(lubridate)
df1<- structure(
list(
Marketname = c("Market1","Market1", "Market2","Market2", "Market3", "Market3"),
Days = c("Sunday","Sunday","Sunday","Sunday", "Sunday","Tuesday"),
Openinghours = c("Morning","Evening", "Morning","Evening","Evening","Evening")
), row.names = c(NA, 6L), class = "data.frame")
ui <- fluidPage(
shiny::navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
br(),
tabPanel("",
sidebarLayout(
sidebarPanel(
dateInput("date", "Which day shift do you choose?"),
selectInput("hours", label = h5("Which work shift do you choose??"), choices = NULL,
selected = ""),
selectInput("market", label = h5("Choose a market??"), choices = NULL,
selected = "")
),
mainPanel(
)
))
))
server <- function(input, output,session) {
observe({
week_day <- wday(input$date, label = TRUE, abbr = FALSE)
updateSelectInput(session, "hours", choices = unique(df1[df1$Days == week_day, 3]))
})
}
shinyApp(ui = ui, server = server)