title: how can I get indexes of a range of co-ordinates in a matrix used to build an Igraph in Shiny R?
body: <p>I am learning Shiny from RStudio and I have a matrix of XY co-ordinates in the format ( 0.28414506, 0.42638248 ) with which I am building an IGraph. Using the brush method I can get the range of XY min max co-ordinates. I want to take the range of co-ordinates and find the index values of points taken in by the brush method. The shiny tutorials for near points work off dataframes but my initial data is a matrix.  </p>
  
  <p>My question is similar to <a href="https://stackoverflow.com/questions/5577727/is-there-an-r-function-for-finding-the-index-of-an-element-in-a-vector">Is there an R function for finding the index of an element in a vector?</a>  but my elements won't be exact matches, they will be a range.  Here's my code so far, any help would be appreciated. </p>
  
  <pre><code>  ui &lt;- basicPage(
    plotOutput("plot1",
           click = "plot_click",
           dblclick = "plot_dblclick",
           hover = "plot_hover",
           brush = "plot_brush"),
  verbatimTextOutput("info")
  )
  
  server &lt;- function(input, output) {
  output$plot1 &lt;- renderPlot({
  plot(g, layout=layout1, rescale=FALSE, axes=TRUE, xlim = range(layout1[,1]), ylim = range(layout1[,2]))
   })
  
  output$info &lt;- renderText({
  xy_str &lt;- function(e) {
    if(is.null(e)) return("NULL\n")
    paste0("x=", round(e$x, 8), " y=", round(e$y, 8), "\n")
  
  }
  xy_range_str &lt;- function(e) {
    if(is.null(e)) return("NULL\n")
    paste0("xmin=", round(e$xmin, 8), " xmax=", round(e$xmax, 8), 
           " ymin=", round(e$ymin, 8), " ymax=", round(e$ymax, 8))
  }
  
  paste0(
    "click: "   , xy_str(input$plot_click),
    "dblclick: ", xy_str(input$plot_dblclick),
    "hover: "   , xy_str(input$plot_hover),
    "brush: "   , xy_range_str(input$plot_brush)
  )
  })
  }
  
  shinyApp(ui, server)
  </code></pre>