Reputation: 651
I have a shiny dashboard page with several graphs that I would like to share a common date selector, but put the graphs into separate modules.
I understand that when I use callModule
that I need to pass along the object using reactive per
If a module needs to access an input that isn’t part of the module, the containing app should pass the input value wrapped in a reactive expression (i.e. reactive(...)):
callModule(myModule, "myModule1", reactive(input$checkbox1))
but, I don't understand what to do on the other side.
in ui:
graphRoFCUI("RoFCNameSpace"),
dateRangeInput("dateRange", "Select Date Range:"
, start = max("2016-6-27", Sys.Date()-366)
, end = Sys.Date()
, min = "2016-6-27"
, max = Sys.Date()
)
in server:
callModule(graphRoFC, id = "RoFCNameSpace", conn, reactive(input$dateRange))
In my module.R:
graphRoFCUI <- function(id) {
ns <- NS(id)
plotlyOutput(outputId = ns("RoFCOverTime"))
}
...
graphRoFC <- function(input, output, session, conn, dateRange) {
limitDateRangePercentRoFCDF <- reactive({
PercentRoFCDF.dateLimited <- subset(PercentRoFCDF, TicketLocalCreatedDate > dateRange[1] & TicketLocalCreatedDate < dateRange[2])
return(PercentRoFCDF.dateLimited)
})
...
}
What I get is:
Warning: Error in $: object of type 'closure' is not subsettable
Stack trace (innermost first):
80: as.Date
79: ggplotly [sdesc.R#43]
78: func
77: origRenderFunc
76: output$RoFCNameSpace-RoFCOverTime
1: runApp
Upvotes: 0
Views: 866
Reputation: 278
Hard to say for sure without looking at the full reproducible code. But whenever you have an error object of type 'closure' is not subsettable
it almost always means you have a reactive object for which you've failed to use ()
. My guess is that you need to change this line:
PercentRoFCDF.dateLimited <- subset(PercentRoFCDF, TicketLocalCreatedDate > dateRange[1] & TicketLocalCreatedDate < dateRange[2])
to
PercentRoFCDF.dateLimited <- subset(PercentRoFCDF, TicketLocalCreatedDate > dateRange()[1] & TicketLocalCreatedDate < dateRange()[2])
Upvotes: 2