【发布时间】:2017-04-11 17:09:54
【问题描述】:
创建了一个应用程序,我想从用户那里获取滑块输入和选择输入,并在我们单击操作按钮时显示它。最初,当我们运行应用程序代码时工作正常,但是当我们更改 sliderInput 和 selectInput 中的值时,输出会自动显示而无需单击按钮。
shinyUI(fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar
sidebarLayout(
sidebarPanel(
sliderInput("tm", "select the interval", min = 0, max = 20,value = 10),
selectInput("samples", label = "Select the sample type", c("Sample A","Sample B","Sample C")),
actionButton("act", label = " Update" )
),
mainPanel(
textOutput("val"),
br(),
textOutput("sam")
)
)
))
shinyServer(function(input, output) {
observe(
if(input$act>0){
output$val <- renderText(
paste("You selected the value" ,input$tm)
)
output$sam <- renderText(input$samples)
}
)
})
我只想在单击操作按钮时更改值。
【问题讨论】: