knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Run the entire script below starting at ### DRYSCRPAE ### through the end (do not run the pbp_list or pbp_df portion). After that has all been run and all functions are loaded, run the ds.compile_games function directly below this.
games <- c(20303:21230) # change here to the directory you want to write the pbp files to dir.create("./data") for (game in games) { # this should be the same as the directory above setwd("./data") # you will need to change the season to reflect what season you want to scrape pbp_list <- ds.compile_games( games = game, season = "20132014", pause = 2, try_tolerance = 5, agents = ds.user_agents ) pbp_df <- pbp_list[[1]] # this creates a new directory inside the above directory to house each game # pbp I do this because I create other stats based on that one pbp file but # if you dont want it you can delete it dir.create(paste0("~/HockeyStuff/xGGameBreakdowns/2014/", as.character(game))) setwd(paste0("~/HockeyStuff/xGGameBreakdowns/2014/", as.character(game))) # this writes the pbp to a text file neccesarry if you want to read it in # again without scraping write_delim(pbp_df, as.character(game), delim = "|") }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.