I'am working with modulizing my shiny app and tried to reproduce a simple example:
library(shiny)
histogramUI <- function(id) {
tagList(
selectInput(NS(id, "var"), "Variable", names(mtcars)),
numericInput(NS(id, "bins"), "bins", 10, min = 1),
plotOutput(NS(id, "hist"))
)
}
histogramServer <- function(id) {
moduleServer(id, function(input, output, session) {
data <- reactive(mtcars[[input$var]])
output$hist <- renderPlot({
hist(data(), breaks = input$bins, main = input$var)
}, res = 96)
})
}
ui <- fluidPage(
histogramUI("hist1")
)
server <- function(input, output, session) {
histogramServer("hist1")
}
shinyApp(ui, server)
But always get the warning
function moduleServer not found
I use Shiny 1.4.0.2 with R 3.6.3 on Linuxmint (amd64)
Has anyone an idea?
Thanks
Christian