


Scale_color_manual( labels = c( "KC ", "PIT "), Geom_hline( yintercept = 0.5, color = "gray ", linetype = "dashed ") + Ggplot(aes( x = game_seconds_remaining, y = wpa, color = team)) + Gather( team, wpa, - game_seconds_remaining) % >% # Now generate the win probability chart: kc_vs_pit_pbp % >%

# Pull out the Steelers and Chief colors: nfl_teamcolors % filter( league = "nfl ")įilter( name = "Pittsburgh Steelers ") % >%įilter( name = "Kansas City Chiefs ") % >% # Install the awesome teamcolors package by Ben Baumer and Gregory Matthews: # install.packages("teamcolors") For example the win probability chartīelow shows how the Chiefs early lead faded in the second quarter,īefore they took sealed the game in the second half: Now using the estimates from the nflscrapR expected points and win Scrape_json_play_by_play function to return the play-by-play data for First,Īccess the tidyverse library to select the game id and then use the Here is an example of scraping the week 2 matchup of the 2018 NFL seasonīetween the Kansas City Chiefs and the Pittsburgh Steelers. #> Loading required package: nnet #> Loading required package: magrittr week_2_games Loading required package: XML #> Loading required package: RCurl #> Loading required package: bitops # Display using the pander package: # install.packages("pander") week_2_games % >%
