Overview

The goal of fitzRoy is to provide a set of functions that allows for users to easily get access to AFL data from sources such as afltables.com and footywire.com. There are also tools for processing and cleaning that data. Future versions will include basic ELO processing functions.

Installation

You can install fitzRoy from github with:

Usage

The fitzRoy package can be used to simply get data from various sources. Some minimal working examples are below.

Getting Data

Primarily, the tool can be used to access data from various sources. Data is included in the package and can be access directly however this will not be up to date. Each source of data has functions for updating data during the season.

AFL Tables match results

You can access the basic afl tables match results data. This includes all matches from 1897-current. It is generally updated on the day after a round finishes.

You can access the data directly from the package using match_results. This will be updated periodically but you will need to update your R package to get access to the latest data. It is better to use get_match_results directly, as this will give you up to date results.

You can also convert this format into a more analysis friendly “long” format using the helper function convert_results.

AFL Tables player results

A new function will return all detailed player stats from afltables.com. Primarily, the easiest way to use this is simply to call get_afltables_stats with your required start_date and end_date.

stats <- get_afltables_stats(start_date = "2000-01-01", end_date = "2018-06-01")
#> Returning data from 2000-01-01 to 2018-06-01
#> Finished getting afltables data

tail(stats)
#> # A tibble: 6 x 59
#>   Season Round Date       Local.start.time Venue Attendance Home.team  HQ1G
#>    <dbl> <chr> <date>                <int> <chr>      <int> <chr>     <int>
#> 1   2018 10    2018-05-27             1440 "Per…      37575 Fremantle     3
#> 2   2018 10    2018-05-27             1440 "Per…      37575 Fremantle     3
#> 3   2018 10    2018-05-27             1440 "Per…      37575 Fremantle     3
#> 4   2018 10    2018-05-27             1440 "Per…      37575 Fremantle     3
#> 5   2018 10    2018-05-27             1440 "Per…      37575 Fremantle     3
#> # … with 1 more row, and 51 more variables: HQ1B <int>, HQ2G <int>,
#> #   HQ2B <int>, HQ3G <int>, HQ3B <int>, HQ4G <int>, HQ4B <int>,
#> #   Home.score <int>, Away.team <chr>, AQ1G <int>, AQ1B <int>, AQ2G <int>,
#> #   AQ2B <int>, AQ3G <int>, AQ3B <int>, AQ4G <int>, AQ4B <int>,
#> #   Away.score <int>, First.name <chr>, Surname <chr>, ID <int>,
#> #   Jumper.No. <dbl>, Playing.for <chr>, Kicks <dbl>, Marks <dbl>,
#> #   Handballs <dbl>, Goals <dbl>, Behinds <dbl>, Hit.Outs <dbl>,
#> #   Tackles <dbl>, Rebounds <dbl>, Inside.50s <dbl>, Clearances <dbl>,
#> #   Clangers <dbl>, Frees.For <dbl>, Frees.Against <dbl>,
#> #   Brownlow.Votes <dbl>, Contested.Possessions <dbl>,
#> #   Uncontested.Possessions <dbl>, Contested.Marks <dbl>,
#> #   Marks.Inside.50 <dbl>, One.Percenters <dbl>, Bounces <dbl>,
#> #   Goal.Assists <dbl>, Time.on.Ground.. <int>, Substitute <int>,
#> #   Umpire.1 <chr>, Umpire.2 <chr>, Umpire.3 <chr>, Umpire.4 <chr>,
#> #   group_id <int>

Footywire Advanced Player Stats

Footywire data is available in the form of advanced player match statistics from 2010 games onwards. This is when advanced statistics became available.

Footywire data from 2010-2017 is included in the package. This will be updated periodically but you will need to update your R package to get access to the latest data.

We can also use the update_footywire_stats function to get the most up to date data. This will merge data from 2010-current with any new data points.

## Update footywire data
dat <- update_footywire_stats()
#> Getting match ID's...
#> Getting player IDs from footywire.com ...
#> Checking data on https://github.com/jimmyday12/fitzRoy/ ...
#> No new matches found - returning data

tail(dat)
#>             Date Season   Round            Venue           Player
#> 81307 2019-03-31   2019 Round 2 Metricon Stadium Cameron McCarthy
#> 81308 2019-03-31   2019 Round 2 Metricon Stadium      Alex Pearce
#> 81309 2019-03-31   2019 Round 2 Metricon Stadium     Joel Hamling
#> 81310 2019-03-31   2019 Round 2 Metricon Stadium  Michael Walters
#> 81311 2019-03-31   2019 Round 2 Metricon Stadium        Rory Lobb
#> 81312 2019-03-31   2019 Round 2 Metricon Stadium       Sean Darcy
#>            Team Opposition Status Match_id CP UP ED   DE CM GA MI5
#> 81307 Fremantle Gold Coast   Away     9738  2  9  8 66.7  0  0   2
#> 81308 Fremantle Gold Coast   Away     9738  8  4  5 41.7  0  0   0
#> 81309 Fremantle Gold Coast   Away     9738  4  5  8 88.9  0  0   0
#> 81310 Fremantle Gold Coast   Away     9738  4  4  5 62.5  0  0   1
#> 81311 Fremantle Gold Coast   Away     9738  5  4  6 85.7  0  0   0
#> 81312 Fremantle Gold Coast   Away     9738  6  1  1 16.7  0  0   0
#>       One.Percenters BO TOG K HB  D M G B T HO GA1 I50 CL CG R50 FF FA AF
#> 81307              0  0  87 9  3 12 3 2 0 1  0   0   2  1  3   1  0  2 52
#> 81308              4  0  92 5  7 12 0 0 0 1  0   0   1  0  5   2  0  3 24
#> 81309              8  0 100 5  4  9 2 0 0 2  0   0   0  0  1   5  1  0 38
#> 81310              2  0  89 7  1  8 3 1 2 4  0   0   2  1  2   0  2  1 55
#> 81311              1  0  86 4  3  7 1 1 1 2 11   0   1  1  2   0  2  0 49
#> 81312              1  0  80 3  3  6 0 0 0 2 37   0   0  3  4   1  0  2 54
#>       SC CCL SCL SI  MG TO ITC T5
#> 81307 49   0   1  6 277  4   0  1
#> 81308 37   0   0  0 175  5   9  0
#> 81309 60   0   0  1  77  0   8  0
#> 81310 50   0   1  5 203  3   0  2
#> 81311 71   1   0  5  82  1   2  0
#> 81312 54   1   2  1  27  2   1  0

Weather

We have also included weather data for the 2017 season. This is a work in progress but includes rainfall data from the nearest observation station to each ground. This data is included in the package as results_weather.

Squiggle Data

You can access data from the Squiggle API where the tips of well known AFL tipping models are collected. See full instructions on the above link.