【发布时间】:2013-09-09 14:29:07
【问题描述】:
我找到了some information,了解如何使用siderbarPanel 中的反应式表达式更改sliderInput 的value。但不是value,我想用numericInput 更改滑块的min 和max。在server.R 的this 脚本中,它说只有label 和value 可以更改滑块。是否有任何其他可能性可以使用响应式表达式更改 sliderInput 的最小/最大值?
这是一个例子:
ui.R:
shinyUI(pageWithSidebar(
#Sidebar with controls to select the variable to plot
sidebarPanel(
#Numeric Inputs
numericInput("min_val", "Enter Minimum Value", 1993),
numericInput("max_val", "Enter Maximum Value", 2013),
#Slider
sliderInput("inSlider", "Slider",
min=1993, max=2013, value=2000),
# Now I would like to change min and max from sliderInput
# by changing the numericInput.
mainPanel()
))
服务器.R:
library(shiny)
shinyServer(function(input, output, session) {
reactive({
x<-input$min_val
y<-input$max_val
updateSliderInput(session, "inSlider", min=x, max=y, value=x)
})
}
【问题讨论】: