我想将input$var中的变量存储到一个对象中,该对象可以与后面的字符串进行比较。现在,我只是尝试通过将其存储到对象value_stored来将其打印在屏幕上。但它不打印任何东西*(错误:无法将类型“闭包”强制转换为“字符”类型的向量*)。这意味着它没有存储价值。
library(shiny)
ui <- fluidPage(
titlePanel("censusVis"),
sidebarLayout(
sidebarPanel(
helpText("Create demographic maps with
information from the 2010 US Census."),
selectInput("var",
label = "Choose a variable to display",
choices = c("Percent White",
"Percent Black",
"Percent Hispanic",
"Percent Asian"),
selected = "Percent White")
),
mainPanel(
textOutput("selected_var")
textOutput("test")
)
)
)
server <- function(input, output) {
output$selected_var <- renderText({
paste(input$var)
})
value_store <- reactive(input$var)
output$test <- renderText({
paste(value_store)
})
# I want to use the value in input$var for some comparision.
# but value_store unable to store. Help.
}
shinyApp(ui = ui, server = server)