This is an extension of the tidytuesday assignment you have already done. Complete the questions below, using the screencast you chose for the tidytuesday assigment.

Import data

library(tidyverse)
theme_set(theme_light())
media_franchises <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-07-02/media_franchises.csv")

Description of the data and definition of variables

media_franchises %>%
  count(franchise, sort = TRUE)
## # A tibble: 103 x 2
##    franchise                                     n
##    <chr>                                     <int>
##  1 Spider-Man                                    7
##  2 Dragon Ball                                   6
##  3 Final Fantasy                                 6
##  4 Neon Genesis Evangelion                       6
##  5 Star Wars                                     6
##  6 Superman                                      6
##  7 Wizarding World / Harry Potter                6
##  8 A Song of Ice and Fire /  Game of Thrones     5
##  9 Aladdin                                       5
## 10 Detective Conan / Case Closed                 5
## # … with 93 more rows
franchises <- media_franchises %>%
  group_by(franchise, original_media, year_created, creators, owners) %>%
  summarize(categories = n(),
            total_revenue = sum(revenue),
            most_profitable = revenue_category[which.max(revenue)]) %>%
  ungroup()
franchises
## # A tibble: 103 x 8
##    franchise original_media year_created creators owners categories
##    <chr>     <chr>                 <dbl> <chr>    <chr>       <int>
##  1 A Song o… Novel                  1996 George … Rando…          5
##  2 Aladdin   Animated film          1992 Walt Di… The W…          5
##  3 Angry Bi… Video game             2009 Jaakko … Rovio           4
##  4 Anpanman  Manga                  1973 Takashi… Froeb…          2
##  5 Assassin… Video game             2007 Patrice… Ubiso…          3
##  6 Avengers  Comic book             1963 Stan Le… Marve…          4
##  7 Barbie    Animated film          1987 Ruth Ha… Mattel          3
##  8 Batman    Comic book             1939 Bob Kan… DC En…          4
##  9 Ben 10    Animated seri…         2005 Man of … Carto…          1
## 10 Beyblade  Manga                  1999 Takao A… Shoga…          2
## # … with 93 more rows, and 2 more variables: total_revenue <dbl>,
## #   most_profitable <chr>
media_franchises
## # A tibble: 321 x 7
##    franchise revenue_category revenue year_created original_media creators
##    <chr>     <chr>              <dbl>        <dbl> <chr>          <chr>   
##  1 A Song o… Book sales         0.9           1996 Novel          George …
##  2 A Song o… Box Office         0.001         1996 Novel          George …
##  3 A Song o… Home Video/Ente…   0.28          1996 Novel          George …
##  4 A Song o… TV                 4             1996 Novel          George …
##  5 A Song o… Video Games/Gam…   0.132         1996 Novel          George …
##  6 Aladdin   Box Office         0.76          1992 Animated film  Walt Di…
##  7 Aladdin   Home Video/Ente…   1             1992 Animated film  Walt Di…
##  8 Aladdin   Merchandise, Li…   0.5           1992 Animated film  Walt Di…
##  9 Aladdin   Music              0.447         1992 Animated film  Walt Di…
## 10 Aladdin   Video Games/Gam…   2.2           1992 Animated film  Walt Di…
## # … with 311 more rows, and 1 more variable: owners <chr>

Visualize data

Hint: One graph of your choice.

library(glue)
top_franchises <- franchises %>%
  mutate(franchise = glue("{ franchise } ({ year_created })")) %>%
  top_n(20, total_revenue)
media_franchises %>%
  mutate(franchise = glue("{ franchise } ({ year_created })")) %>%
  semi_join(top_franchises, by = "franchise") %>%
  mutate(franchise = fct_reorder(franchise, revenue, sum),
         revenue_category = fct_reorder(revenue_category, revenue, sum)) %>%
  ggplot(aes(franchise, revenue)) +
  geom_col(aes(fill = revenue_category)) +
  geom_text(aes(y = total_revenue,
                label = paste0(scales::dollar(total_revenue, accuracy = 1), "B")),
            data = top_franchises,
            hjust = 0) +
  scale_y_continuous(labels = scales::dollar) +
  expand_limits(y = 100) +
  coord_flip() +
  theme(panel.grid.major.y = element_blank()) +
  guides(fill = guide_legend(reverse = TRUE)) +
  labs(title = "What are the most profitable franchises of all time?",
       fill = "Category",
       x = "",
       y = "Revenue (Billions)")

What is the story behind the graph?

The graph desplays the biggest franchises of all time. The colors in the graph are the categorys in withch they are broken down to make a profit, with the number being desplayed to the right in billions. Categorys are, merchandise, video games, box office, comic, home/entertainment, book sales, tv, music.

Hide the messages, but display the code and its results on the webpage.

Write your name for the author at the top.

Use the correct slug.