Skip to content

Instantly share code, notes, and snippets.

@trinker
Created March 19, 2015 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trinker/3f4a8e18c0a3d15d7fee to your computer and use it in GitHub Desktop.
Save trinker/3f4a8e18c0a3d15d7fee to your computer and use it in GitHub Desktop.
An R script to search through baby names
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