title: Interactive R graph
body: <p>I have an R plot and I'd like the user to be able to click a spot on the graph, and I'd like to know where they clicked. Sort of like a mouse listener. I'm using RStudio. Is this possible in any way? Basically, for a point they click on, I want to display another plot with more details about that point.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>data &lt;- data.frame(x=c(1,2,3,4,5),y=c(1,2,3,4,5))
  x11()
  plot(data)
  
  loc &lt;- locator(n=1)
  if(loc$x &gt; 2) {
    x11()
    plot(c(1,2,3),c(5,6,7))
  }
  
  loc &lt;- locator(n=1)
  if(loc$x &gt; 2) {
    x11()
    plot(c(4,5,6),c(5,6,7))
  }
  </code></pre>
  
  <p>So, the first plot comes up that has 5 data points. If the user clicks past an x value of 2, then I want to open another plot, which plots the data points you see listed (3 data points). Then, if they close that plot and they click past 2 AGAIN on the original, 5 data point plot, then I want it to open up a new plot with the 3 data points you see in the second if statement.</p>
  
  <p>But it's giving me errors and I/O issues.</p>