title: nearPoints not able to automatically infer `xvar` from shiny coordinfo
body: <p>I am trying to find the points in a <code>ggplot</code> near a mouse click using the <code>nearPoints</code> function, but it is not working. I used the code below to create shiny app with two plots for <code>diamonds</code> data.frame:</p>
  
  <pre><code>library(shiny)
  library(ggplot2)
  ui &lt;- fluidPage(
  mainPanel(
  uiOutput("tb")
  )
  )
  server &lt;- function(input,output){
  
     output$diamonds1 &lt;- renderPlot({
  
          print(ggplot(diamonds, aes(x=carat, y=price, col=clarity)) + 
                                  geom_point(alpha=0.5)+ facet_wrap(~color, scales="free"))
     })
     output$diamonds2 &lt;- renderPlot({
  
          print(ggplot(diamonds, aes(x=carat, y=price, col=clarity)) + 
                                 geom_point(alpha=0.5)+ facet_wrap(~cut, scales="free"))
     }) 
  
     output$info &lt;- renderPrint({
  
          nearPoints(diamonds, input$plot_click, threshold = 10, maxpoints = 1,
                     addDist = TRUE)
     })
  
  output$tb &lt;- renderUI({
  tabsetPanel(tabPanel("First plot", 
                       plotOutput("diamonds1")),
              tabPanel("Second plot", 
                       plotOutput("diamonds2", click = "plot_click"), 
                       verbatimTextOutput("info"))) 
  })
  }
  shinyApp(ui = ui, server = server) 
  </code></pre>
  
  <p>I keep getting this error in the second plot</p>
  
  <blockquote>
    <p>Error: nearPoints: not able to automatically infer <code>xvar</code> from coordinfo</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/ITHQX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ITHQX.png" alt="enter image description here"></a></p>
  
  <p>Any suggestions would be appreciated?</p>