Chapter 42 Ten Most Active Characters
We want to find out which characters have spoken the most in the episodes. Here the top Ten are being displayed.
detach(package:plyr)
rm(list=ls())
fillColor = "#FFA07A"
fillColor2 = "#F1C40F"
Scripts = read_csv("input/simpsons_script_lines.csv")
Characters = read_csv("input/simpsons_characters.csv")
Scripts$character_id = as.integer(Scripts$character_id)
ScriptsCharacters = left_join(Scripts,Characters,
by = c("character_id" = "id") )
ScriptsCharacters = ScriptsCharacters %>%
filter(!is.na(name))
TopCharacters = ScriptsCharacters %>%
group_by(name) %>%
tally(sort = TRUE)
ggplot(head(TopCharacters,10), aes(x = reorder(name, n),
y = n)) +
geom_bar(stat='identity',colour="white", fill = fillColor) +
geom_text(aes(x = name, y = 1, label = paste0("(",n,")",sep="")),
hjust=0, vjust=.5, size = 4, colour = 'black',
fontface = 'bold') +
labs(x = 'name', y = 'Count Of Sentences', title = 'Ten Most Active Characters') +
coord_flip() +
theme_bw()
If you are not familiar with the characters like me , Wikipedia is there to help. Lets hop to Wikipedia and get the details. I have the following information from Wikipedia.
Homer Jay Simpson is a fictional character and the main protagonist of the American animated television series The Simpsons as the patriarch of the eponymous family.
Homer and his wife Marge have three children: Bart, Lisa, and Maggie. As the family’s provider, he works at the Springfield Nuclear Power Plant as safety inspector.
Charles Montgomery Burns, known as C. Montgomery Burns and Monty Burns, but usually referred to simply as Mr. Burns, occasionally as Mr Snrub, is a recurring character in the animated television series The Simpsons, and is voiced by Harry Shearer. Mr. Burns is the evil owner of the Springfield Nuclear Power Plant and is also Homer Simpson’s boss. He is assisted at almost all times by Waylon Smithers, his loyal and sycophantic aide, adviser, confidant and secret admirer.
Moe Szyslak is the proprietor and bartender of Moe’s Tavern, a Springfield bar frequented by Homer Simpson, Barney Gumble, Carl Carlson, Lenny Leonard, Sam, Larry, and others.