Using ggplot to explore #AFLW 2019 performances

I have been looking at the #AFLW 2019 data. I took the opportunity to include some CRAN packages I have not used before.

The data (two csv files) and my code are in a GitHub repository (link). My code is very basic and reflects my own thinking out loud as a I learn more about R.

In the past, I have tended to bookmark R suggestions and yet never manage to return to them as the list gets longer. My new practice is to create an R file to explore packages or code that strike me as interesting.

I used patchwork (link) and ggforce (link) in addition to ggrepel (link) to look at the data in the context of ggplot2 (link).

I was particularly interested in how patchwork helped me combine a range of images.

These work really well as PDF A4 pages and I thought they would be helpful summaries to stimulate conversation.

The three plot example above is:

Women’s T20 Group Games

In the lull between the Group Games and the semi-finals of the Women’s T20 Cricket World Cup, I have been looking at the data I have collected and trying out some ggplot visualisation.

My attempts with the ggridges package failed and I am going to re-try. But in the meantime, here are two comparisons that use the ggrepel package. My data are for the total runs scored in each wicket partnerships. The data do not include the games decided by Duckworth-Lewis methods (England v Bangladesh).

I used Baptiste Auguie’s suggestions for laying out multiple plots (two in my case) and installed the grid and gridExtra packages to help me.

Scoring first and losing in association football: some European data

I have a particular interest in teams that score first and lose in six of the European football leagues.

We are up to: week 4 of the 2018-2019 season in England, France and the Netherlands; week 3 in Italy and Spain; and week 2 in Germany.

So far, there have been 22 games in these leagues in which the team that scored first lost:

The csv file is available on GitHub.

I used ggplot2 and ggrepel in RStudio to explore these data.

The games were:

The scores were:

The teams that came back from conceding the first goal were:

My code example (using geom_label_repel) is:

library(ggplot2)
library(ggrepel)
df2 <- read_csv(“SFL05.csv”)
ggplot(data=df2, aes(x=League, y=TE, label=Game)) +
geom_point() +
xlab(“League”) +
ylab(“Time to Equalise (in Minutes)”) +
labs(title = “Games in which the team that scores first loses”) +
geom_label_repel(size=3)

I found Kamil Slowikowski’s ggrepel examples particularly helpful.

Photo Credit

Heracles Almelo (Twitter)