title: How to add interactive scaling on Shiny dual Y axis graph line
body: <p>I'm trying to make an interactive graph in Shiny where you can use a slider to change a scaling value for one of the lines on a dual Y axis graph. <a href="https://i.stack.imgur.com/jfrJ1.png" rel="nofollow noreferrer">Here is what the base graph looks like</a></p>
  <p>The code I am using to plot the graph in Shiny is below, my aim was to define the &quot;coeff&quot; variable as the input of a slider in the UI, and to then incorporate this into how the values of the line were calculated</p>
  <pre><code>###Shiny dual Y axis plot
  
  library(shiny)
  library(ggplot2)
  
  ui &lt;- fluidPage(
    titlePanel(&quot;Line Graph&quot;),
    sidebarLayout(
      sidebarPanel(
        sliderInput(&quot;scalegvt&quot;,&quot;Scale Government Data by:&quot;,  min = 0.03, max = 1.0, value = c(1.0))
      ),
      
      mainPanel(
        plotOutput(&quot;distPlot&quot;)
      )
    )
  )
  
  ## Creating server logic
  server &lt;- function(input, output) {
    coeff &lt;- reactive({
      req(input$scalegvt)
    })
    output$distPlot &lt;- renderPlot({ #Rendering plot
      compggp &lt;- ggplot(NULL, aes(x = date, y = covid)) +
        geom_spline(data = onsdf, 
                    aes(x = date, y = covid, colour = &quot;ONS Modelled Estimates&quot;), nknots = 90, size = 1.3) +
        geom_spline(data = gvtdf, 
                    aes(x = date, y = covid/coeff, colour = &quot;Gvt Reported Positive Tests&quot;), nknots = 90, 
                    size = 1.3)##This is the section I want to make reactive to &quot;coeff&quot;##
      
      #Stringency bars
      compggp &lt;- compggp + purrr::pmap(strindf, barfunction)
      
      #Adding aesthetics
      compggp &lt;- compggp + scale_x_date(limits = as.Date(c(&quot;2020-05-03&quot;, NA ))) +
        theme_minimal() +
        scale_y_continuous(labels = scales::comma) +
        labs(x = &quot;Date (year - month)&quot;, y = &quot;Covid Cases (estimated and reported)&quot;) + 
        scale_y_continuous(labels = scales::comma, name = &quot;Modelled Population Estimates&quot;, 
                           sec.axis = sec_axis(~.*coeff, name = &quot;Reported Positive Tests&quot;)) +
        scale_colour_manual(name = &quot;&quot;,
                            values = c(&quot;ONS Modelled Estimates&quot;=&quot;khaki4&quot;, 
                                       &quot;Gvt Reported Positive Tests&quot; = &quot;darkcyan&quot;,
                                       &quot;Lockdown Stringency&quot; = &quot;red&quot;))
      compggp
    })
  }
  
  # Running application
  shinyApp(ui = ui, server = server)
  </code></pre>
  <p>I'm not actually getting any error messages from this code; the slider and the graph both render properly but just don't interact with each other.</p>
  <p>Many thanks!</p>