Hi there,
I am trying to update a select input based on another select input. I'm not sure why it isn't working, but it is getting complex as I am trying to use modules to avoid replication. I have created a minimal (arguably) example:
library(shiny)
commonUI <- function(id) {
ns <- NS(id)
tagList(
selectInput(ns('year'), 'Survey year', choices = c('All'='*','2018','2016','2014','2012','2010'), selected = '2018'),
selectInput(ns('by'), 'Plot by', choices = c('All','Sex','Year group', 'Survey year'))
)
}
prepdata <- function(input, output, session, by = NULL){
yearupdate <- reactive({
ns <- session$ns
if(by == 'Survey year'){
updateSelectInput(session, ns('year'), selected = '*')
}
})
}
ui <- fluidPage(
tabsetPanel(
tabPanel('Summary',
commonUI('tab1')
),
tabPanel('Custom',
commonUI('tab2')
)
)
)
server <- function(input, output, session){
summdat <- callModule(prepdata, 'tab1', by = reactive(input$by))
custdat <- callModule(prepdata, 'tab2', by = reactive(input$by))
}
shinyApp(ui, server)
If anyone knows why it isn't working, I would love to know! 
I'm still new at using modules!
Will