title: How to make Shiny click input on plot remain?
body: <p>I've been having a problem with a reactive plot in R's Shiny package. I would like to colour certain variables based on clicking one variable. Below is a rather contrived example using mtcars that highlights based on cylinder. The initial colouring works, but disappears straight away.</p>
  
  <p>server side:</p>
  
  <pre><code>#server. R
  library(shiny)
  library(ggplot2)
  library(stringr)
  library(dplyr)
  library(datasets)
  data(mtcars)
  
  function(input, output)
  {
  
  
  output$plot &lt;- reactivePlot(function()
  {
   if (is.null(input$clicker) == TRUE){
    graph &lt;- ggplot()+
      theme_bw()+
      geom_point(data = mtcars, 
                 aes(x = disp, y = cyl))+
      guides(color=FALSE)+
      theme(legend.position = "none")+
      labs(x = "Displacement",
           y = "Cylinders")
    return(graph)
  }
  else{
    x &lt;-reactive({ 
      x &lt;- nearPoints(mtcars, input$clicker, threshold = 10, maxpoints = 1,
                      addDist = TRUE, xvar = "disp", yvar = "cyl")[1,2]
    })
  
    print(x())
  
    mtcars$colour &lt;- NA
    myval &lt;- x()
    mtcars$colour[which(mtcars$cyl == myval)] &lt;- "var"
    plot &lt;- ggplot()+
      theme_bw()+
      geom_point(data = mtcars[mtcars$cyl != myval,], 
                 aes(x = disp, y = cyl, color = colour))+
      geom_point(data = mtcars[mtcars$cyl == myval,], 
                 aes(x = disp, y = cyl, color = colour), size = 4)+
      guides(color=FALSE)+
      theme(legend.position = "none")+
      labs(x = "Displacement",
           y = "Cylinders")
    return(plot)
  }
  })
   }
  </code></pre>
  
  <p>UI side:</p>
  
  <pre><code>shinyUI(fluidPage(
  
   sidebarLayout(position = "right",
              sidebarPanel(
                h3("Instructions"),
                helpText("Lorem Ipsum.")
                ),
              mainPanel(
                plotOutput('plot', click = "clicker")
              )
  )
  )
  )
  </code></pre>
  
  <p>Is there a variable in the click selection I have missed to make the variable remain? I have used this in examples and it was okay, so I'm guessing it's something to do with the actual plot rendering? Apologies in advance for the daft question..</p>