Skip to content

Instantly share code, notes, and snippets.

@benjaminrobinson
Last active August 4, 2017 14:32
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 benjaminrobinson/86b56afd0bdc599a6670d67ba671a7ee to your computer and use it in GitHub Desktop.
Save benjaminrobinson/86b56afd0bdc599a6670d67ba671a7ee to your computer and use it in GitHub Desktop.
library(rvest)
library(dplyr)
library(tidyr)
nfl <- data.frame()
for(a in letters[!(letters %in% c('q','x','z'))]){
tmp <- read_html(
paste0("http://www.espn.com/nfl/college/_/letter/",a)
) %>%
html_node("table") %>%
html_table %>%
rename(player=X1,team=X2,position=X3) %>%
filter(player!='PLAYER') %>%
mutate(college=ifelse(player %in% intersect(.$player,.$team),player,NA)) %>%
fill(college) %>%
filter(player!=college)
nfl <- rbind(nfl,tmp)
print(a)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment