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 <dbl>,
#> #   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/ ...
#> New data found for 54 matches - downloading from footywire.com...
#> Getting data from footywire.com
#> Finished getting data

tail(dat)
#>             Date Season    Round         Venue         Player     Team
#> 84079 2019-08-11   2019 Round 21 Optus Stadium  Taylor Walker Adelaide
#> 84080 2019-08-11   2019 Round 21 Optus Stadium  Darcy Fogarty Adelaide
#> 84081 2019-08-11   2019 Round 21 Optus Stadium     Sam Jacobs Adelaide
#> 84082 2019-08-11   2019 Round 21 Optus Stadium Lachlan Murphy Adelaide
#> 84083 2019-08-11   2019 Round 21 Optus Stadium    Eddie Betts Adelaide
#> 84084 2019-08-11   2019 Round 21 Optus Stadium  Kyle Hartigan Adelaide
#>       Opposition Status Match_id CP UP ED   DE CM GA MI5 One.Percenters BO
#> 84079 West Coast   Away     9900  6  5  9 75.0  1  0   1              1  0
#> 84080 West Coast   Away     9900  2 10  9 75.0  1  1   4              0  0
#> 84081 West Coast   Away     9900  6  5  7 63.6  1  0   0              3  0
#> 84082 West Coast   Away     9900  4  7  9 81.8  0  1   0              1  0
#> 84083 West Coast   Away     9900  4  5  6 66.7  1  0   1              0  0
#> 84084 West Coast   Away     9900  4  5  7 77.8  0  0   0              7  0
#>       TOG  K HB  D M G B T HO GA1 I50 CL CG R50 FF FA AF SC CCL SCL SI  MG
#> 84079  85  8  4 12 3 2 1 1  0   0   0  0  3   0  3  1 58 52   0   0  4 241
#> 84080  87 10  2 12 7 5 0 0  0   1   3  0  1   0  0  1 82 81   0   0  6 311
#> 84081  85  6  5 11 4 0 0 6 36   0   2  2  3   0  1  2 95 84   0   2  4 124
#> 84082  80  6  5 11 2 1 0 2  0   1   1  0  0   0  1  0 49 52   0   0  3 177
#> 84083  84  4  5  9 3 1 1 3  0   0   1  0  3   0  0  1 47 43   0   0  4 150
#> 84084  88  5  4  9 3 0 0 3  0   0   0  1  2   4  1  2 39 52   0   1  0  91
#>       TO ITC T5
#> 84079  4   0  0
#> 84080  1   0  0
#> 84081  2   5  1
#> 84082  2   0  2
#> 84083  3   0  2
#> 84084  2   3  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.