Danny Malter

Data Science Manager - Accenture
M.S. in Predictive Analytics - DePaul University

Danny Malter

Me
Malter Analytics
GitHub
LinkedIn
YouTube Channel
Twitter
Kaggle

Other Work
General Assembly
AriBall

Media
Built In

Game of Thrones US Baby Names

Updated: 5/13/2019

library(readr)
library(babynames)
library(ggplot2)
library(ggthemes)
library(scales)
library(gridExtra)
library(dplyr)
library(knitr)

# data comes from https://www.ssa.gov/oact/babynames/limits.html


names2018 <- read_csv("~/Downloads/names/yob2018.txt", 
                      col_names = c("name", "sex", "n"), col_types = cols(sex = col_character()))
names2018$year <- 2018
names2018 <- names2018[c("year", "sex", "name", "n")]
names2018 <- names2018 %>%
  group_by(year, name) %>%
  summarise(n = sum(n))

babynames <- subset(babynames, year >= 2011 & year <= 2017)
babynames$prop <- NULL
babynames <- babynames %>%
  group_by(year, name) %>%
  summarise(n = sum(n))

babynames.df <- rbind(babynames, names2018)

arya <- subset(babynames.df, name == "Arya")
khaleesi <- subset(babynames.df, name == "Khaleesi")
yara <- subset(babynames.df, name == "Yara")
lyanna <- subset(babynames.df, name == "Lyanna")
daenerys <- subset(babynames.df, name == "Daenerys")
shae <- subset(babynames.df, name == "Shae")
renly <- subset(babynames.df, name == "Renly")
jory <- subset(babynames.df, name == "Jory")
tyrion <- subset(babynames.df, name == "Tyrion")
brienne <- subset(babynames.df, name == "Brienne")
sansa <- subset(babynames.df, name == "Sansa")
catelyn <- subset(babynames.df, name == "Catelyn")
ellaria <- subset(babynames.df, name == "Ellaria")
oberyn <- subset(babynames.df, name == "Oberyn")
nymeria <- subset(babynames.df, name == "Nymeria")
ramsay <- subset(babynames.df, name == "Ramsay")
theon <- subset(babynames.df, name == "Theon")
aerys <- subset(babynames.df, name == "Aerys")
gregor <- subset(babynames.df, name == "Gregor")
shireen <- subset(babynames.df, name == "Shireen")
talisa <- subset(babynames.df, name == "Talisa")
sandor <- subset(babynames.df, name == "Sandor")

# Arya
arya.plot <- ggplot(arya, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 2750), breaks = seq(0, 2750, 250), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Arya') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
arya.plot

# Khaleesi
khaleesi.plot <- ggplot(khaleesi, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 600), breaks = seq(0, 600, 50), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Khaleesi') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
khaleesi.plot

# Yara
yara.plot <- ggplot(yara, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 500), breaks = seq(0, 500, 50), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Yara') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
yara.plot

# Lyanna
lyanna.plot <- ggplot(lyanna, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 350), breaks = seq(0, 350, 50), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Lyanna') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
lyanna.plot

# Daenerys
daenerys.plot <- ggplot(daenerys, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 200), breaks = seq(0, 200, 50), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Daenerys') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
daenerys.plot

# Shae
shae.plot <- ggplot(shae, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 160), breaks = seq(0, 160, 20), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Shae') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
shae.plot

# Renly
renly.plot <- ggplot(renly, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 115), breaks = seq(0, 115, 10), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Renly') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
renly.plot

# Jory
jory.plot <- ggplot(jory, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 75), breaks = seq(0, 75, 5), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Jory') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
jory.plot

# Tyrion
tyrion.plot <- ggplot(tyrion, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 75), breaks = seq(0, 75, 5), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Tyrion') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
tyrion.plot

# Brienne
brienne.plot <- ggplot(brienne, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 40), breaks = seq(0, 40, 5), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Brienne') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
brienne.plot

# Sansa
sansa.plot <- ggplot(sansa, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 35), breaks = seq(0, 35, 5), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Sansa') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
sansa.plot

# Ramsay
ramsay.plot <- ggplot(ramsay, aes(x = year)) + 
  geom_line(aes(y = n, colour="#00BFC4"), size=1.0) + #blue
  scale_x_continuous(limits = c(2011, 2018), breaks = seq(2011,2018,1)) +
  scale_y_continuous(limits = c(0, 30), breaks = seq(0, 30, 5), labels = comma) +
  xlab('Year') + 
  ylab('Count') +
  ggtitle('Ramsay') + 
  theme(axis.line = element_line(size=1, colour = "black"),
        panel.grid.major = element_line(colour = "#d3d3d3"), panel.grid.minor = element_blank(),
        panel.border = element_blank(), panel.background = element_blank()) +
  theme(plot.title = element_text(size = 10, hjust = 0.5, family = "Tahoma", face = "bold"),
        text=element_text(family="Tahoma"),
        axis.text.x=element_text(colour="black", size = 10),
        axis.text.y=element_text(colour="black", size = 10),
        legend.key=element_rect(fill="white", colour="white")) +
  theme(legend.position="none")
ramsay.plot

# 2018 Name Counts (at least 10 names)

count.df <- rbind(subset(arya, year==2018), 
      subset(khaleesi, year==2018),
      subset(yara, year==2018),
      subset(lyanna, year==2018),
      subset(daenerys, year==2018),
      subset(shae, year==2018),
      subset(renly, year==2018),
      subset(jory, year==2018),
      subset(tyrion, year==2018),
      subset(brienne, year==2018),
      subset(sansa, year==2018),
      subset(catelyn, year==2018),
      subset(ellaria, year==2018),
      subset(oberyn, year==2018),
      subset(nymeria, year==2018),
      subset(ramsay, year==2018),
      subset(theon, year==2018),
      subset(aerys, year==2018),
      subset(gregor, year==2018),
      subset(shireen, year==2018),
      subset(talisa, year==2018),
      subset(sandor, year==2018))

kable(count.df[,c('name', 'n')], 
    caption = "2018 Name Counts (at least 10 names)")
2018 Name Counts (at least 10 names)
name n
Arya 2594
Khaleesi 560
Yara 441
Lyanna 319
Daenerys 163
Shae 125
Renly 102
Jory 72
Tyrion 58
Brienne 33
Sansa 29
Catelyn 21
Ellaria 17
Oberyn 15
Nymeria 15
Ramsay 15
Theon 14
Aerys 14
Gregor 11
Shireen 11
Talisa 11
Sandor 10
comments powered by Disqus