我想要做的是提取名称输入为字符串的对象的值。 R函数get()在R中执行我想要的但在Shiny中没有。在R中,这将是
> a <- 1
> get("a")
[1] 1
In Shiny我收到错误。
ui.R:
shinyUI(fluidPage(
fluidRow(
column(4,
sliderInput("slider", label = h3("Slider Range"), min = 0,
max = 100, value = c(40, 60))
)
)
))
server.R:
library(shiny)
shinyServer(function(input, output) {
output$range <- renderPrint({ input$slider })
observe({
print(get("input$slider"))
})
})
错误:
Listening on http://127.0.0.1:4035
Warning: Error in get: object 'input$slider' not found
Stack trace (innermost first):
56: get
55: print
54: observerFunc [C:\Users\statsmart\Desktop/server.R#6]
1: runApp
ERROR: [on_request_read] connection reset by peer
相反,我希望控制台打印
[1] 40 60