Session Ready
Exercise

purrr and histograms

Now you're going to put together everything you've learned, starting with two different lists, which will be turned into a faceted histogram. You're going to work again with the Stars Wars data from the sw_films and sw_people datasets to answer a question:

  • What is the distribution of heights of characters in each of the Star Wars films?

Different movies take place on different sets of planets, so you might expect to see different distributions of heights from the characters. Your first task is to transform the two datasets into dataframes since ggplot() requires a dataframe input. Then you will join them together, and plot the result, a histogram with a different facet, or subplot, for each film.

Instructions
100 XP
  • Create a dataframe with the "title" of each film, and the "characters" from each film in the sw_films dataset.
  • Create a dataframe with the "height", "mass", "name", and "url" elements from sw_people.
  • Join the two dataframes together using the "characters" and "url" keys.
  • Create a ggplot() histogram with x = height, faceted by filmtitle.