Step 1: Load the Dataset

# Load dataset (make sure 'Netflix.csv' is in your working directory)
Netflix <- read.csv("Netflix.csv", stringsAsFactors = FALSE)

# View first few rows
head(Netflix)
##    show_id    type                                   title
## 1 81145628   Movie Norm of the North: King Sized Adventure
## 2 80117401   Movie              Jandino: Whatever it Takes
## 3 70234439 TV Show                      Transformers Prime
## 4 80058654 TV Show        Transformers: Robots in Disguise
## 5 80125979   Movie                            #realityhigh
## 6 80163890 TV Show                                 Apaches
##                   director
## 1 Richard Finn, Tim Maltby
## 2                         
## 3                         
## 4                         
## 5         Fernando Lebrija
## 6                         
##                                                                                                                                                                                 cast
## 1                                        Alan Marriott, Andrew Toth, Brian Dobson, Cole Howard, Jennifer Cameron, Jonathan Holmes, Lee Tockar, Lisa Durupt, Maya Kay, Michael Dobson
## 2                                                                                                                                                                   Jandino Asporaat
## 3 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
## 4                                                           Will Friedle, Darren Criss, Constance Zimmer, Khary Payton, Mitchell Whitfield, Stuart Allan, Ted McGinley, Peter Cullen
## 5           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
## 6                                                                                                      Alberto Ammann, Eloy Azorín, Verónica Echegui, Lucía Jiménez, Claudia Traisac
##                                    country        date_added release_year
## 1 United States, India, South Korea, China September 9, 2019         2019
## 2                           United Kingdom September 9, 2016         2016
## 3                            United States September 8, 2018         2013
## 4                            United States September 8, 2018         2016
## 5                            United States September 8, 2017         2017
## 6                                    Spain September 8, 2017         2016
##     rating duration
## 1    TV-PG   90 min
## 2    TV-MA   94 min
## 3 TV-Y7-FV 1 Season
## 4    TV-Y7 1 Season
## 5    TV-14   99 min
## 6    TV-MA 1 Season
##                                                           listed_in
## 1                                Children & Family Movies, Comedies
## 2                                                   Stand-Up Comedy
## 3                                                          Kids' TV
## 4                                                          Kids' TV
## 5                                                          Comedies
## 6 Crime TV Shows, International TV Shows, Spanish-Language TV Shows
##                                                                                                                                            description
## 1         Before planning an awesome wedding for his grandfather, a polar bear king must take back a stolen artifact from an evil archaeologist first.
## 2    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.
## 3         With the help of three human allies, the Autobots once again protect Earth from the onslaught of the Decepticons and their leader, Megatron.
## 4                       When a prison ship crash unleashes hundreds of Decepticons on Earth, Bumblebee leads a new Autobot force to protect humankind.
## 5 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.
## 6             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.

Step 2: Transform the Data

Netflix_Actor <- Netflix %>%
  separate_rows(cast, sep = ", ") %>%
  drop_na(cast) %>%
  rename(actor = cast)

Step 3: Find the 6 Actors with the Most Appearances in TV Shows

Top_Actors <- Netflix_Actor %>%
  select(type, actor) %>%
  filter(type == "TV Show") %>%
  group_by(actor) %>%
  summarise(Appearances = n()) %>%
  arrange(desc(Appearances)) %>%
  head(6)

Top_Actors
## # A tibble: 6 × 2
##   actor                Appearances
##   <chr>                      <int>
## 1 ""                           210
## 2 "Takahiro Sakurai"            18
## 3 "Yuki Kaji"                   16
## 4 "Daisuke Ono"                 14
## 5 "David Attenborough"          14
## 6 "Ashleigh Ball"               12

Step 4: Visualize the Results

ggplot(Top_Actors, aes(x = reorder(actor, Appearances), y = Appearances, fill = actor)) +
  geom_col(show.legend = FALSE) +
  coord_flip() +
  labs(title = "Top 6 Most Frequent TV Show Actors on Netflix",
       x = "Actor",
       y = "Number of TV Show Appearances")