Interactive / reactive change of minimum / maximum values ​​sliderInput

I found some information on how to change the value sliderInput to a reactive expression in siderbarPanel . But instead of value I would like to change the min and max slider using numericInput . This script for server.R says that only the label and value can be changed for the sliders. Is there any other way to change the min / max sliderInput with a reactive expression?

Here is an example:

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() )) 

server.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) }) 
+8
r shiny
source share
1 answer

I think this is best done using the brilliant dynamic interface functions via renderUI() and uiOutput() . Try the following example:

ui.R

 library(shiny) shinyUI(pageWithSidebar( headerPanel("Test Shiny App"), sidebarPanel( #Numeric Inputs numericInput("min_val", "Enter Minimum Value", 1993), numericInput("max_val", "Enter Maximum Value", 2013), #display dynamic UI uiOutput("slider") ), mainPanel() )) 

server.R

 library(shiny) shinyServer(function(input, output, session) { #make dynamic slider output$slider <- renderUI({ sliderInput("inSlider", "Slider", min=input$min_val, max=input$max_val, value=2000) }) }) 
+10
source share

All Articles