Created
March 19, 2015 01:53
-
-
Save trinker/3f4a8e18c0a3d15d7fee to your computer and use it in GitHub Desktop.
An R script to search through baby names
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
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load(babynames, dplyr) | |
lapply(seq(1, 50000, by=35), function(n){ | |
babynames %>% | |
filter(year > 1940 & year < 1980) %>% | |
group_by(name, sex) %>% | |
summarize(n=sum(n))%>% | |
ungroup %>% | |
arrange(desc(n)) %>% | |
filter_(sex=="F") %>% | |
`[`(n:(n + 35), ) %>% | |
select(c(1, 3)) %>% | |
print(n=35) | |
cat(sprintf("\nNames: %s - %s\n", n, n + 35)) | |
flush.console() | |
cat("Press [enter] to continue\n") | |
ans <- readline() | |
if (ans != "") { | |
stop("So you've had enough then?") | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment