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 - R Tutorial
From the course: R: Interactive Visualizations with htmlwidgets
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
What is the Plotly library?9m 50s
-
(Locked)
Make ggplot2 interactive using Plotly7m 27s
-
(Locked)
Create interactive stacked bar charts9m 3s
-
(Locked)
Interactive scatter, line, and bubble charts with Leaflet8m 15s
-
(Locked)
Create interactive maps8m 47s
-
(Locked)
Specify custom colors7m 11s
-
(Locked)
Customize tooltips4m 33s
-
(Locked)
Combine multiple charts7m 18s
-
(Locked)
Extract click information from Plotly6m 22s
-
-
-
-
-