I’m creating a shiny app where I would like to allow the user to give the value in a list a reactive name. In the minimal example below I would like to have the dropdown menu value (“example1”) be assigned as the name of the value in the list. I was thinking of using glue
({{}}
) to make it interactive like this:
library(shiny)
ui <- fluidPage(
titlePanel("Make reactive a named list"),
sidebarLayout(
sidebarPanel(
selectInput("choices",
"Make a choice",
c("example1", "example2", "example3"))
),
mainPanel(
textOutput("text")
)
)
)
server <- function(input, output) {
data <- reactive({
list("{{input$choices}}" = TRUE)
})
output$text <- renderPrint({
data()
})
}
shinyApp(ui = ui, server = server)
Current output:
Unfortunately, this doesn’t work. As we can see from the output the reactive input$choices
value is not assigned to the list. So my expected output would be: $example2 [1] TRUE
. So I was wondering if anyone knows how to assign a reactive value to a list like this?
Recognized by R Language Collective