title: Add reactive values from click events to existing data frame and update plot
body: <p>I'm new to using Shiny and having some problems with adding reactive values to an existing data frame.</p>
  
  <p>I would like to plot a scatter plot with a regression line using some preexisting data and update it with user clicks. I found a helpful example, but I can't figure out how to store the reactive values in a data frame in order to update the regression line.</p>
  
  <p>Here is what I tried. Thank you.</p>
  
  <pre><code>    library(shiny)
  
  ui &lt;- basicPage(
    plotOutput("plot1", click = "plot_click"),
    verbatimTextOutput("info"),
    actionButton("updateplot", "Update Plot:"),
    actionButton("refreshlinie", "Rlinie"),
  )
  
  server &lt;- function(input, output) {
  
    var1 &lt;- c(3, 10, 15, 3, 4, 7, 1, 12, 8, 18, 20, 4, 4, 5, 10)
    var2 &lt;- c(4, 10, 12, 17, 15, 20, 14, 3, 4, 15, 12, 5, 5, 6, 2)
    df &lt;- cbind (var1, var2)
  
    val &lt;- reactiveValues(clickx = NULL, clicky = NULL, data = NULL)
    observe({
      input$plot_click
      isolate({
        val$clickx = c(val$clickx, input$plot_click$x)
        val$clicky = c(val$clicky, input$plot_click$y)
        })
  
     # isolate({
        # val$data = rbind(df, c(val$clickx, val$clicky))   
      #})
  
    }) #adding clicks to list
  
  
    output$plot1 &lt;- renderPlot({
      plot(val$data[,1], val$data[,2])
      input$updateplot
      isolate({
        points(val$clickx, val$clicky)
      })
        if(input$refreshlinie)
      abline(lm(val$data[,1]~ val$data[,2]))
    })
  
    output$info &lt;- renderText({
      paste0("x = ", val$clickx, ", y = ",val$clicky, "\n")
    })
  
  }
  
  shinyApp(ui, server)
  </code></pre>