I would like to use do.call
to run render family functions, like renderPrint()
. Below code doesn't work:
rm(list=ls())
library(shiny)
ui <- fluidPage(
selectInput("select", label = h3("Select box"),
choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3),
selected = 1),
hr(),
fluidRow(column(3, verbatimTextOutput("value")))
)
server <- function(input, output, session) {
output$value <- do.call("renderPrint", list({ input$select }))
}
shinyApp(ui, server)
Error:
Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
Stack trace (innermost first):
45: .getReactiveEnvironment()$currentContext
44: .subset2(x, "impl")$get
43: $.reactivevalues
[...]
How to achieve this? I am guessing that this is somehow connected with environment and lazy evaluation, so closure might the solution, but this is only guessing...