nearPoints function availability in R plotly

Hi community,

Thanks for the plotly package.

I have been using the plotly package for the development of shiny apps. In the shiny dashboard, I would like to show the near points to a selected point and build up on the resultant information. There is a nice option in shiny, nearPoints, for identifying the near point(s) present within a distance. However, I could not find an equivalent function in the plotly environment?

The selected point information is shared using the plot_click event. As the plot_click and plotly_click events have a different structure for sharing the data, nearPoints can not be used directly.

Example of plotly_click event data:

curveNumber pointNumber x y key

Example of plot_click event data:

List of 7
 $ x      : num 2.49
 $ y      : num 32.9
 $ mapping: Named list()
 $ domain :List of 4
  ..$ left  : num 1.36
  ..$ right : num 5.58
  ..$ bottom: num 9.46
  ..$ top   : num 34.8
 $ range  :List of 4
  ..$ left  : num 59
  ..$ right : num 260
  ..$ bottom: num 276
  ..$ top   : num 58
 $ log    :List of 2
  ..$ x: NULL
  ..$ y: NULL
 $ .nonce : num 0.853
1 Like

Hi @peranti thanks for your question. Did you already got your answer here ?

Hi @sckott,

Carson suggested an approach for getting the solution. Currently, I am working on the solution. If it works, I will update the question with the solution.

Thanks for checking :slight_smile:

Sounds good, thanks for the update