Loading Required Libraries

library(tidyverse)
library(knitr)

Loading the Netflix Dataset

# Read the Netflix dataset
Netflix <- read_csv("Netflix.csv")

# Display the structure of the dataset
glimpse(Netflix)
## Rows: 6,234
## Columns: 12
## $ show_id      <dbl> 81145628, 80117401, 70234439, 80058654, 80125979, 8016389…
## $ type         <chr> "Movie", "Movie", "TV Show", "TV Show", "Movie", "TV Show…
## $ title        <chr> "Norm of the North: King Sized Adventure", "Jandino: What…
## $ director     <chr> "Richard Finn, Tim Maltby", NA, NA, NA, "Fernando Lebrija…
## $ cast         <chr> "Alan Marriott, Andrew Toth, Brian Dobson, Cole Howard, J…
## $ country      <chr> "United States, India, South Korea, China", "United Kingd…
## $ date_added   <chr> "September 9, 2019", "September 9, 2016", "September 8, 2…
## $ release_year <dbl> 2019, 2016, 2013, 2016, 2017, 2016, 2014, 2017, 2017, 201…
## $ rating       <chr> "TV-PG", "TV-MA", "TV-Y7-FV", "TV-Y7", "TV-14", "TV-MA", …
## $ duration     <chr> "90 min", "94 min", "1 Season", "1 Season", "99 min", "1 …
## $ listed_in    <chr> "Children & Family Movies, Comedies", "Stand-Up Comedy", …
## $ description  <chr> "Before planning an awesome wedding for his grandfather, …

Data Exploration

# Display first few rows
head(Netflix) %>% kable()
show_id type title director cast country date_added release_year rating duration listed_in description
81145628 Movie Norm of the North: King Sized Adventure Richard Finn, Tim Maltby Alan Marriott, Andrew Toth, Brian Dobson, Cole Howard, Jennifer Cameron, Jonathan Holmes, Lee Tockar, Lisa Durupt, Maya Kay, Michael Dobson United States, India, South Korea, China September 9, 2019 2019 TV-PG 90 min Children & Family Movies, Comedies Before planning an awesome wedding for his grandfather, a polar bear king must take back a stolen artifact from an evil archaeologist first.
80117401 Movie Jandino: Whatever it Takes NA Jandino Asporaat United Kingdom September 9, 2016 2016 TV-MA 94 min Stand-Up Comedy Jandino Asporaat riffs on the challenges of raising kids and serenades the audience with a rousing rendition of “Sex on Fire” in his comedy show.
70234439 TV Show Transformers Prime NA Peter Cullen, Sumalee Montano, Frank Welker, Jeffrey Combs, Kevin Michael Richardson, Tania Gunadi, Josh Keaton, Steve Blum, Andy Pessoa, Ernie Hudson, Daran Norris, Will Friedle United States September 8, 2018 2013 TV-Y7-FV 1 Season Kids’ TV With the help of three human allies, the Autobots once again protect Earth from the onslaught of the Decepticons and their leader, Megatron.
80058654 TV Show Transformers: Robots in Disguise NA Will Friedle, Darren Criss, Constance Zimmer, Khary Payton, Mitchell Whitfield, Stuart Allan, Ted McGinley, Peter Cullen United States September 8, 2018 2016 TV-Y7 1 Season Kids’ TV When a prison ship crash unleashes hundreds of Decepticons on Earth, Bumblebee leads a new Autobot force to protect humankind.
80125979 Movie #realityhigh Fernando Lebrija Nesta Cooper, Kate Walsh, John Michael Higgins, Keith Powers, Alicia Sanz, Jake Borelli, Kid Ink, Yousef Erakat, Rebekah Graf, Anne Winters, Peter Gilroy, Patrick Davis United States September 8, 2017 2017 TV-14 99 min Comedies When nerdy high schooler Dani finally attracts the interest of her longtime crush, she lands in the cross hairs of his ex, a social media celebrity.
80163890 TV Show Apaches NA Alberto Ammann, Eloy Azorín, Verónica Echegui, Lucía Jiménez, Claudia Traisac Spain September 8, 2017 2016 TV-MA 1 Season Crime TV Shows, International TV Shows, Spanish-Language TV Shows A young journalist is forced into a life of crime to save his father and family in this series based on the novel by Miguel Sáez Carral.

Transforming the Data

Transform the data so that for each TV show, every actor has a row. Rename the column name “cast” to “actor”.

# Separate actors in the cast column and rename the column
Netflix_Actor <- Netflix %>% 
  separate_rows(cast, sep = ", ") %>% 
  drop_na(cast) %>% 
  rename(actor = cast)

# Display the transformed data
head(Netflix_Actor) %>% kable()
show_id type title director actor country date_added release_year rating duration listed_in description
81145628 Movie Norm of the North: King Sized Adventure Richard Finn, Tim Maltby Alan Marriott United States, India, South Korea, China September 9, 2019 2019 TV-PG 90 min Children & Family Movies, Comedies Before planning an awesome wedding for his grandfather, a polar bear king must take back a stolen artifact from an evil archaeologist first.
81145628 Movie Norm of the North: King Sized Adventure Richard Finn, Tim Maltby Andrew Toth United States, India, South Korea, China September 9, 2019 2019 TV-PG 90 min Children & Family Movies, Comedies Before planning an awesome wedding for his grandfather, a polar bear king must take back a stolen artifact from an evil archaeologist first.
81145628 Movie Norm of the North: King Sized Adventure Richard Finn, Tim Maltby Brian Dobson United States, India, South Korea, China September 9, 2019 2019 TV-PG 90 min Children & Family Movies, Comedies Before planning an awesome wedding for his grandfather, a polar bear king must take back a stolen artifact from an evil archaeologist first.
81145628 Movie Norm of the North: King Sized Adventure Richard Finn, Tim Maltby Cole Howard United States, India, South Korea, China September 9, 2019 2019 TV-PG 90 min Children & Family Movies, Comedies Before planning an awesome wedding for his grandfather, a polar bear king must take back a stolen artifact from an evil archaeologist first.
81145628 Movie Norm of the North: King Sized Adventure Richard Finn, Tim Maltby Jennifer Cameron United States, India, South Korea, China September 9, 2019 2019 TV-PG 90 min Children & Family Movies, Comedies Before planning an awesome wedding for his grandfather, a polar bear king must take back a stolen artifact from an evil archaeologist first.
81145628 Movie Norm of the North: King Sized Adventure Richard Finn, Tim Maltby Jonathan Holmes United States, India, South Korea, China September 9, 2019 2019 TV-PG 90 min Children & Family Movies, Comedies Before planning an awesome wedding for his grandfather, a polar bear king must take back a stolen artifact from an evil archaeologist first.

Finding the 6 Actors with Most Appearances in TV Shows

# Finding the 6 actors that have the most appearances on TV show
top_6_actors <- Netflix_Actor %>%
  select(type, actor) %>% 
  filter(type == "TV Show") %>% 
  group_by(actor) %>% 
  count(sort = TRUE) %>% 
  ungroup() %>% 
  head()

# Display results
top_6_actors %>% 
  kable(col.names = c("Actor", "Number of TV Shows"))
Actor Number of TV Shows
Takahiro Sakurai 18
Yuki Kaji 16
Daisuke Ono 14
David Attenborough 14
Ashleigh Ball 12
Hiroshi Kamiya 12

Visualization

# Create bar chart
ggplot(top_6_actors, aes(x = reorder(actor, n), y = n, fill = actor)) +
  geom_col(show.legend = FALSE) +
  geom_text(aes(label = n), hjust = -0.2, size = 5) +
  coord_flip() +
  labs(
    title = "Top 6 Actors with Most Appearances in Netflix TV Shows",
    x = "Actor",
    y = "Number of TV Shows"
  ) +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold"),
    axis.text = element_text(size = 11)
  ) +
  scale_fill_brewer(palette = "Set2")