3MW (Creating interactive visualizations with R)

Guten Tag!

Many greetings from Ulm, Germany. Welcome to this year's last 3MW newsletter. After today's issue, 3MW will be on break until January, 18.

No analytics dashboard can survive without interactive visualizations. Case in point, here's a screenshot from my Typefully dashboard.

As you can see, there's a box currently showing my followers count from Dec 07. That's because my (invisible) cursor was hovering over that specific part of the line.

This behavior makes it easy to explore your data. And today I'll point you towards two ways to create such interactive visualizations with R.

Turn ggplots into plotly objects

Using the {plotly} package is my favorite way to create interactive visuals. Why? Because I don't have to think much about how that works.

That's because {plotly} has a function called ggplotly() which is just magical. It can take a regular ggplot and turn it into an interactive plotly object.

Here's an example. This is a regular ggplot. It shows me the number of flights in 2013 from NYC. The data is courtesy of the {nycflights13} package.

Now, here's the same plot but transformed into a plotly object. It's not a perfect match but it's quite close. And notice that you can get more information via a tooltip window by hovering over a tile.

Of course, you can always add a little bit of fine-tuning to the plot later on. For a more thorough intro to {plotly}, you can check out one of my old blog posts.

Build an echart

Another very popular package is {echarts4r}. It brings the popular echarts.js library to R. Here's a similar heat map about the NYC flights using this package.

Notice that the colorbar legend is interactive. It shows you the value of the box my (invisible) cursor is hovering over. We will lean more on this package in the future of this newsletter as it offers many cool features. For now, though, I will leave you with this excellent YT intro from Sharon Machlis.

Build an analytics dashboard in less than one hour

Interactive visualizations are only one part of dashboards. But if you combine them with, say,

  • an interactive table,

  • large value boxes and

  • a few sliders

then you've got your own analytics dashboard right there.

For example, you could build your own Twitter analytics dashboard in less than one hour. My new micro-course shows you exactly how to do that. If you're interested, you can find it on my Courses page.

That's a wrap! As always, I'm happy to hear your feedback about this week's issue. Feel free to write me on Twitter or reply to this mail.

And of course I wish you happy holidays and a great end of the year. See you in the new year!

Enjoy the rest of your day!Albert

Did you like this post and want to support more content like this? Whenever you feel like it, you can support me with a coffee or a membership.

Need help visualizing your data? Or need to build a Shiny app? I'm open to freelance work. You can book a free 30-minute Zoom meeting with me and we can find out if I'm a good match for your project.

Reply

or to participate.