Guest User

Untitled

a guest
Jun 21st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. for (id in pitchIDs$playerid) {
  2. url <- paste("https://www.fangraphs.com/statsd.aspx?
  3. playerid=",id,"&position=P&type=&gds=&gde=&season=all")
  4. gamelogs <- url %>%
  5. read_html() %>%
  6. html_nodes(xpath = '//*[@id="DailyStats1_dgSeason1_ctl00"]') %>%
  7. html_table()
  8. gamelogs$id <- id
  9. }
  10.  
  11. data = c()
  12. for(id in pitchIDs$playerid) {
  13. url <- read_html(paste0("https://www.fangraphs.com/statsd.aspx?
  14. playerid=",id,"&position=P&type=&gds=&gde=&season=all"))
  15. gamelogs <- url %>%
  16. html_nodes(xpath = '//*[@id="DailyStats1_dgSeason1_ctl00"]') %>%
  17. html_table()
  18. gamelogs <- gamelogs[[1]]
  19. gamelogs$id <- id
  20. if(is.data.frame(data)) {
  21. names(gamelogs) = names(data)
  22. data = rbind(data, gamelogs)
  23. } else {
  24. data = gamelogs
  25. }
  26. }
Add Comment
Please, Sign In to add comment