I want to create a selectInput()
within a modalDialog()
. And also create a reactive dataset based on that selectInput()
. However i get the error message:
Warning: Error in : Problem with `filter()` input `..1`.
i Input `..1` is `name == input$selectName`.
x Input `..1` must be of size 87 or 1, not size 0.
[No stack trace available]
Whereas I can create the input of my numericInput()
reactively within the renderText()
. Where is the difference there? Is there a possibilty to create reactive Data within a modalDialog()
?
library(shiny)
library(tidyverse)
data = starwars
ui = fluidPage(
div(style = "margin-top: 50px; display: flex; justify-content: center;",
actionButton(inputId = "openModal", label = "Open"))
)
server = function(input, output, session){
observeEvent(input$openModal, {
reactiveData = reactive({
data %>% filter(name == input$selectName)
})
output$added = renderText({input$add})
showModal(
modalDialog(
title = NULL, easyClose = T, size = "m", footer = modalButton("back"),
tagList(
div(selectInput(inputId = "selectName", label = NULL, choices = data$name)),
div(numericInput(inputId = "add", label = NULL, value = 0)),
div(reactiveData()%>%pull(height)),
div(textOutput(outputId = "added"))
))
)
})
}
shinyApp(ui, server)