Skip to content

Instantly share code, notes, and snippets.

@romainfrancois
Created October 4, 2017 10:31
Show Gist options
  • Save romainfrancois/246da2a916dcb72b60cf1533b0e70276 to your computer and use it in GitHub Desktop.
Save romainfrancois/246da2a916dcb72b60cf1533b0e70276 to your computer and use it in GitHub Desktop.
library(prenoms)
library(babynames)
library(ggplot2)
library(dplyr)
nnames <- function(data, origin){
data %>%
group_by(sex, year) %>%
summarise(n = length(unique(name))) %>%
mutate( origin = origin ) %>%
arrange(year)
}
data <- bind_rows(
nnames( prenoms, "fr"),
nnames( babynames, "us"),
)
ggplot(data, aes(year, n, color = sex, group = origin) ) +
geom_point() +
facet_grid( ~ origin )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment