Skip to content

Instantly share code, notes, and snippets.

@dalejbarr
Created September 9, 2016 13:40
Show Gist options
  • Save dalejbarr/a1faee4c34f23406c625d7533500c9ac to your computer and use it in GitHub Desktop.
Save dalejbarr/a1faee4c34f23406c625d7533500c9ac to your computer and use it in GitHub Desktop.
R script for analyzing Scottish babynames
library(dplyr)
library(readr)
library(ggplot2)
dat <- read_csv("babies-first-names-all-names-all-years2.csv")
# pull out babies born in 1998
dat98 <- filter(dat, yr == 1998) %>%
group_by(sex) %>%
filter(rank <= 5)
top10 <- semi_join(dat, dat98 %>% select(sex, FirstForename),
c("sex", "FirstForename"))
ggplot(top10, aes(yr, number, colour = FirstForename)) +
geom_line() + facet_wrap(~sex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment