admin管理员组

文章数量:1399949

I've scoured SO for the answer to this question, and I have tried solutions from multiple threads, so I am not sure what I continue to do wrong with this. I am trying to make a master filter list for my app. Those filters will then feed into a SQL query so I can load the necessary data. I cannot get the filters to work correctly when I put them into a separate module. I've made a minimal reproducible example here that should just print out what is stored in my filters, which is how I've been troubleshooting. This code gives me the error: cannot find function "filters". When I remove the parentheses after filters in testServer, I get $options reactive({ input$options })

library(shiny)
library(shinycssloaders)

filtersUI <- function(id) {
  ns <- NS(id)
  
  tagList(
    # Program input ------
    selectInput(
      inputId = ns('options'),
      label = 'Select program(s):',
      choices = c('A','B','C','D'),
      multiple = TRUE
    )
  )
}

filtersServer <- function(id){
  moduleServer(id, function(input,output,session){
    return(
      list(
        options = reactive({input$options})
        )
    )
  })
}

testUI <- fluidPage(
  filtersUI('inputs'),
  textOutput('filters') %>% 
    withSpinner()
)

testServer <- function(input,output,session) {
    filters <- filtersServer('inputs')
     
    output$filters <- renderPrint({
      filters()
    })
}

shinyApp(ui=testUI,server=testServer)

本文标签: Getting inputs from a separate module in R ShinyStack Overflow