not_cran <- identical(Sys.getenv("NOT_CRAN"), "true") online <- !is.null(curl::nslookup("r-project.org", error = FALSE)) eval_param <- not_cran & online knitr::opts_chunk$set( eval = eval_param, message = FALSE, warning = FALSE, collapse = TRUE, comment = "#>" ) library(fitzRoy) library(dplyr)
Functions have been added to fitzRoy to plot and analyse AFL score worms
plot_score_worm
- Plots the score difference between two teams throughout a given match.plot_score_worm_totals
- Plots the total scores of both teams throughout a given match.fetch_score_worm_data
- Returns score data used to plot score worms for a given matchThe plot_score_worm
, plot_score_worm
, and plot_score_worm
functions accepts the argumentmatch_id
to fetch the plot/data for a given match.
match_id
- the Champion Data match_id of the form CD_MSSSS014RRMM where SSSS is the Season, RR is the Round and MM is the Match. e.g. 'CD_M20240142004'The following are some examples of ways to plot and scrape the score worm data.
Fist we can plot the score worm for the 2024 round 20 game between Fremantle and West Coast.
plot_score_worm('CD_M20240142004')
We can also plot the total scores of each team throughout the game.
plot_score_worm_totals('CD_M20240142004')
We can also just return the data for the fixture that can be used to construct these plots or for other score analysis.
fetch_score_worm_data('CD_M20240142004')
We can return multiple games worth of data by passing in a vector of match_ids.
fetch_score_worm_data(c('CD_M20240142101','CD_M20240142102','CD_M20240142103'))
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.