I am trying to figure out how to get 2 R Shiny widgets to update each other. For example, a slider widget that can update a text window widget and vice versa, where the end user can select one of the widgets.
This question is similar, but there is no answer, so I give what (hopefully) a simpler example. Getting reactive dependencies, as shiny :: reactive () did . If this question is answered elsewhere, I could not find such an answer.
I would like to know if I can move slider1 to move slider2 and slider2 to move slider1. Right now I can only do the first part (I can move slider1 to move slider2). If I can do this, I think I can make widget 1 a slider, and widget 2 a numeric one with the same code.
The example below has been modified from http://shiny.rstudio.com/gallery/update-input-demo.html and this is the minimum example I could do. This was the only application that I could find, getting closer to what I was looking for, although I understand that a completely different approach may be required ...
Server .R code
shinyServer( function(input, output, clientData, session) { #### one way interaction between slider 1 and 2 #### observe({![enter image description here][1] c_label <- input$control_label c_num <- input$control_num # <- input$inSlider # Slider input ============================================= updateSliderInput(session, "inSlider", label = paste("Slider2", c_label), value = c_num) updateSliderInput(session, "control_num", label = paste("Slider1", c_label), value = c_num) }) })
Code Ui.r
shinyUI(fluidPage( titlePanel("One Way Reactive Slider"), fluidRow( column(3, wellPanel( h4("Slider Inputs"), sliderInput("control_num", "This controls values:", min = 1, max = 20, value = 15), sliderInput("inSlider", "Slider input:", min = 1, max = 20, value = 15) )) ) ))
