(This article was first published on r – Jumping Rivers, and kindly contributed to R-bloggers)

Ever wonder what an evolving gif of each premier league team's goal difference vs points would look like made in R? Look no further! Most of this is going to be setting up the data (as always) instead of actually plotting the data. To get the data into shape, we’re going to be using the tidyverse and lubridate, which you can install the usual way via install.packages(). To animate the data we’ll be using the gganimate package. This is not on CRAN and so must be installed from GitHub, which you can do so via the devtools package

devtools::install_github("thomasp85/gganimate")

To get started let's attach the relevant packages

library("tidyverse")
library("lubridate")
library("gganimate")

We're going to use the last full season of matches in the premier league, which was the 17/18 season. The data was sourced from football-data.co.uk

prem = read_csv("http://www.football-data.co.uk/mmz4281/1718/E0.csv")
head(prem)

## # A tibble: 6 x 65
##   Div   Date  HomeTeam AwayTeam  FTHG  FTAG FTR    HTHG  HTAG HTR   Referee
##