Created
April 29, 2019 22:30
-
-
Save arvi1000/df0b7689e32c85ba8e57523264b856cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(babynames) | |
library(tidyverse) | |
babynames::babynames %>% | |
filter(name=='Arya') %>% | |
ggplot(aes(x=year, y=prop*100, color=sex)) + | |
geom_line(size=1) + | |
labs(title = 'Babies Named Arya', | |
subtitle = 'as a proportion of all births that year', | |
y='%') + | |
scale_color_manual(values = c(F='pink', M='dodgerblue')) |
Compare multiple names and label certain years with vertical lines:
library(babynames)
library(tidyverse)
babynames::babynames %>%
filter(name %in% c('Katrina', 'Camille')) %>%
group_by(year, name) %>%
summarise(prop=sum(prop)) %>%
ggplot(aes(x=year, y=prop*100, color=name)) +
geom_vline(xintercept = c(1969,2005), linetype = 'dotted') +
geom_line(size=1) +
labs(title = 'Births by name',
subtitle = 'as a proportion of all births that year',
y='%')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternate version with supply-your-own regex: