Chapter 49 Location of Characters
LocationCharacters = ScriptsCharacters %>%
group_by(name,raw_location_text) %>%
tally()
locationOfCharacters <- function(nameOfCharacter) {
SCLocation = LocationCharacters %>%
filter(name == nameOfCharacter) %>%
arrange(desc(n)) %>%
head(10)
titlePlot = paste0(nameOfCharacter,"'s Location")
ggplot(SCLocation, aes(x = reorder(raw_location_text, n),
y = n)) +
geom_bar(stat='identity',colour="white", fill = fillColor2) +
geom_text(aes(x = raw_location_text, y = 1, label = paste0("(",n,")",sep="")),
hjust=0, vjust=.5, size = 4, colour = 'black',
fontface = 'bold') +
labs(x = 'Counts in Locations', y = 'Locations',
title = titlePlot) +
coord_flip() +
theme_bw()
}
49.1 Homers Location
locationOfCharacters("Homer Simpson")
Homer is usually at home , Moe’s Tavern and his work place Springfield Nuclear Power Plant.
49.2 Marge’s Location
locationOfCharacters("Marge Simpson")
49.3 Bart’s Location
locationOfCharacters("Bart Simpson")
49.4 Lisa’s Location
locationOfCharacters("Lisa Simpson")