From the course: R: Interactive Visualizations with htmlwidgets

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Extract click information from Plotly

Extract click information from Plotly - R Tutorial

From the course: R: Interactive Visualizations with htmlwidgets

Start my 1-month free trial

Extract click information from Plotly

- [Instructor] Shiny allows interactive web applications to be built using the R language. Let's see how we can embed a plotly htmlwidget inside of a Shiny app and extract the click information from it. To start, let's see the skeleton of my Shiny app. In our exercise files, let's open server.R. I'll minimize the environment because I don't need to see it for now. We can see inside of the renderPlotly function, lines 12 through 27 generate me a ggplot object which I store against gg_facet_weather, and then we can see we used a function ggplotly to convert the static ggplot2 visualization into an interactive plotly chart. Let's view this Shiny app by clicking Run App, and we can see I have my facet wrapped ggplot2 visualation converted into an interactive plotly chart. I have a tooltip and I'm also able to zoom in on my charts as well. The interactivity I'd like is that when I click on one of these markers, it updates the text here to read, clicked marker coordinates are, so on and so…

Contents