From the course: R: Interactive Visualizations with htmlwidgets

Unlock the full course today

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

Combine multiple charts

Combine multiple charts - R Tutorial

From the course: R: Interactive Visualizations with htmlwidgets

Start my 1-month free trial

Combine multiple charts

- [Instructor] Plotly provides fairly useful tools for combining charts together to share the same axes. Let's look at an example of how to do that in our exercise files. Let's open up subplots.r and we're going to minimalize my environment because I don't need to see it, and at the top of the script file we load three libraries. First, the tidyverse, which we evaluate with command enter. Then, we load the gapminder library which provides us with the gap minder dataset, then a plotly library, which we use to create our interactive charts. Then, on line five through 12, we're creating ourselves a new variable called gapminer_continents, and we can see what we're doing with gapminder on like seven. We pipe gapminder into mutate_if to convert integer columns into double columns, then we pipe into the verb group_by. We group our data by continent and then by year. Then, line eight through 10, we're using mutate to add a couple of new columns. First, we calculate the population of each…

Contents