Using ggplot2 3.0.0 and shiny: nearPoints() problem



Back in the ggplot2 2.2.1 days, the nearPoints() function in shiny could automatically infer xvar and yvar in ggplot2. This made it great when passing different dataframes to the same reactive function.

Since ggplot2 3.0.0, this automatic mapping identification simply does not work. The Error: Data has ### rows, replacement has 0. I suspect this has to do with the tidyverse changes. Does anyone know how to properly construct ggplot() under ggplot2 3.0.0 to properly identify xvar and yvar without explicitly referencing them? Or has this functionality been permanently removed?


I think it should work if you use the latest development version of shiny. You can install it with:


If you still have problems, can you file an issue on the Shiny issue tracker?


Can you point me in the direction to file an issue tracker? It's my first rodeo. The dev channel for shiny doesn't currently address the problem, but thanks for sharing.

The problem is that all plot interactivity with ggplot2 3.0 is not mapping to the data of the plot (despite specifying xvar & yvar when necessary), it's that it is reading pixels. For example, if my plot has a height of 465 pixels and I brush the lower left corner, I will get y ~ 465 regardless of what is actually in the data was in the ggplot (in this hypothetical, 0). I don't see any workaround until shiny is updated to be compatible with ggplot2 3.0.

Thanks for responding.


You can file issues on GitHub here (for Shiny, in this case):


Thanks! Issue posted here.