Overview

We have included a function to interface with the Fryzigg API. This data set includes advanced AFL stats that are typically not available on existing open data sites such as footywire.com and afltables.com. Many thanks to Fryzigg on providing this API interfect.

Load packages

First we need to grab a few packages. If you don’t have any of these, you’ll need to install them.

library(fitzRoy)
library(dplyr)
library(elo)
library(lubridate)

Getting Data

The primary way to access the data is via the get_fryzigg_stats() function. This function provides an easy interface to the Fryzigg API. It takes two arguments - start and end which are the years in which data will be returned (inclusive). They should be provided in YYYY format.

dat <- fitzRoy::get_fryzigg_stats(start = 2019, end = 2019)

We can get a quick view the the fields returned from the fryzigg API.

dplyr::glimpse(dat)
#> Rows: 9,108
#> Columns: 80
#> $ venue_name                     <chr> "MCG", "MCG", "MCG", "MCG", "MCG", "MC…
#> $ match_id                       <int> 15408, 15408, 15408, 15408, 15408, 154…
#> $ match_home_team                <chr> "Carlton", "Carlton", "Carlton", "Carl…
#> $ match_away_team                <chr> "Richmond", "Richmond", "Richmond", "R…
#> $ match_date                     <chr> "2019-03-21", "2019-03-21", "2019-03-2…
#> $ match_local_time               <chr> "19:25:00", "19:25:00", "19:25:00", "1…
#> $ match_attendance               <int> 85016, 85016, 85016, 85016, 85016, 850…
#> $ match_round                    <chr> "1", "1", "1", "1", "1", "1", "1", "1"…
#> $ match_home_team_goals          <int> 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,…
#> $ match_home_team_behinds        <int> 10, 10, 10, 10, 10, 10, 10, 10, 10, 10…
#> $ match_home_team_score          <int> 64, 64, 64, 64, 64, 64, 64, 64, 64, 64…
#> $ match_away_team_goals          <int> 14, 14, 14, 14, 14, 14, 14, 14, 14, 14…
#> $ match_away_team_behinds        <int> 13, 13, 13, 13, 13, 13, 13, 13, 13, 13…
#> $ match_away_team_score          <int> 97, 97, 97, 97, 97, 97, 97, 97, 97, 97…
#> $ match_margin                   <int> 33, 33, 33, 33, 33, 33, 33, 33, 33, 33…
#> $ match_winner                   <chr> "Richmond", "Richmond", "Richmond", "R…
#> $ match_weather_temp_c           <int> 25, 25, 25, 25, 25, 25, 25, 25, 25, 25…
#> $ match_weather_type             <chr> "OVERCAST", "OVERCAST", "OVERCAST", "O…
#> $ player_id                      <int> 12464, 12584, 12341, 12686, 11931, 119…
#> $ player_first_name              <chr> "Nathan", "Jack", "Kane", "Noah", "Mav…
#> $ player_last_name               <chr> "Broad", "Graham", "Lambert", "Balta",…
#> $ player_height_cm               <int> 192, 181, 178, 194, NA, 175, 186, 179,…
#> $ player_weight_kg               <int> 89, 82, 77, 100, NA, 82, 83, 76, 91, 9…
#> $ player_is_retired              <lgl> FALSE, FALSE, FALSE, FALSE, TRUE, FALS…
#> $ player_team                    <chr> "Richmond", "Richmond", "Richmond", "R…
#> $ guernsey_number                <int> 35, 34, 23, 38, 16, 3, 28, 17, 4, 9, 3…
#> $ kicks                          <int> 4, 16, 12, 5, 9, 10, 9, 10, 18, 10, 16…
#> $ marks                          <int> 1, 7, 7, 2, 2, 1, 5, 4, 4, 1, 4, 6, 3,…
#> $ handballs                      <int> 4, 7, 18, 0, 6, 10, 13, 7, 12, 22, 13,…
#> $ disposals                      <int> 8, 23, 30, 5, 15, 20, 22, 17, 30, 32, …
#> $ effective_disposals            <int> 6, 16, 23, 4, 14, 14, 15, 13, 19, 26, …
#> $ disposal_efficiency_percentage <int> 75, 70, 77, 80, 93, 70, 68, 77, 63, 81…
#> $ goals                          <int> 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1,…
#> $ behinds                        <int> 0, 1, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0,…
#> $ hitouts                        <int> 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ tackles                        <int> 2, 6, 4, 1, 1, 7, 5, 2, 0, 6, 1, 1, 2,…
#> $ rebounds                       <int> 2, 0, 1, 0, 2, 0, 0, 0, 1, 2, 4, 5, 5,…
#> $ inside_fifties                 <int> 0, 5, 3, 3, 3, 5, 5, 4, 7, 2, 5, 1, 3,…
#> $ clearances                     <int> 0, 4, 3, 1, 1, 4, 3, 2, 5, 8, 1, 1, 0,…
#> $ clangers                       <int> 2, 6, 4, 5, 1, 2, 7, 0, 7, 3, 1, 1, 4,…
#> $ free_kicks_for                 <int> 1, 1, 2, 1, 0, 3, 1, 1, 0, 3, 1, 1, 1,…
#> $ free_kicks_against             <int> 0, 1, 0, 3, 0, 0, 2, 0, 3, 1, 0, 0, 1,…
#> $ brownlow_votes                 <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,…
#> $ contested_possessions          <int> 3, 9, 10, 2, 4, 9, 10, 6, 15, 22, 6, 4…
#> $ uncontested_possessions        <int> 5, 15, 19, 4, 11, 11, 15, 10, 17, 10, …
#> $ contested_marks                <int> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,…
#> $ marks_inside_fifty             <int> 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,…
#> $ one_percenters                 <int> 6, 2, 0, 2, 2, 1, 0, 2, 2, 0, 0, 1, 4,…
#> $ bounces                        <int> 2, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0,…
#> $ goal_assists                   <int> 0, 0, 0, 0, 0, 1, 1, 2, 1, 0, 0, 0, 1,…
#> $ time_on_ground_percentage      <int> 80, 81, 89, 52, 85, 78, 79, 88, 79, 89…
#> $ afl_fantasy_score              <int> 32, 106, 112, 29, 60, 80, 83, 67, 81, …
#> $ supercoach_score               <int> 45, 88, 95, 18, 63, 82, 67, 82, 109, 1…
#> $ centre_clearances              <int> 0, 2, 0, 1, 0, 1, 2, 1, 2, 5, 0, 0, 0,…
#> $ stoppage_clearances            <int> 0, 2, 3, 0, 1, 3, 1, 1, 3, 3, 1, 1, 0,…
#> $ score_involvements             <int> 0, 5, 9, 2, 4, 7, 6, 9, 11, 5, 7, 2, 8…
#> $ metres_gained                  <int> 187, 475, 412, 223, 313, 342, 328, 317…
#> $ turnovers                      <int> 1, 5, 4, 2, 3, 3, 4, 1, 8, 3, 5, 2, 4,…
#> $ intercepts                     <int> 3, 3, 4, 1, 1, 3, 0, 1, 2, 4, 3, 6, 6,…
#> $ tackles_inside_fifty           <int> 0, 1, 1, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0,…
#> $ contest_def_losses             <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ contest_def_one_on_ones        <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,…
#> $ contest_off_one_on_ones        <int> 0, 0, 0, 2, 0, 0, 0, 2, 3, 2, 0, 0, 0,…
#> $ contest_off_wins               <int> 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0,…
#> $ def_half_pressure_acts         <int> 7, 13, 10, 4, 2, 13, 3, 5, 3, 11, 5, 6…
#> $ effective_kicks                <int> 3, 12, 7, 4, 8, 7, 5, 7, 10, 6, 9, 9, …
#> $ f50_ground_ball_gets           <int> 0, 1, 0, 0, 0, 2, 1, 1, 1, 1, 2, 0, 0,…
#> $ ground_ball_gets               <int> 2, 6, 7, 0, 2, 6, 6, 5, 9, 16, 5, 4, 5…
#> $ hitouts_to_advantage           <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ hitout_win_percentage          <dbl> 0.0, 0.0, 0.0, 31.6, 0.0, 0.0, 0.0, 0.…
#> $ intercept_marks                <int> 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 2, 0,…
#> $ marks_on_lead                  <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,…
#> $ pressure_acts                  <int> 10, 23, 28, 11, 18, 26, 16, 11, 6, 21,…
#> $ rating_points                  <dbl> 6.1, 8.7, 11.5, 5.1, 11.8, 14.5, 4.7, …
#> $ ruck_contests                  <int> 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0…
#> $ score_launches                 <int> 0, 0, 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 2,…
#> $ shots_at_goal                  <int> 0, 1, 2, 2, 2, 0, 1, 2, 0, 0, 1, 0, 1,…
#> $ spoils                         <int> 6, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 3,…
#> $ subbed                         <chr> "Not Subbed", "Not Subbed", "Not Subbe…
#> $ player_position                <chr> "INT", "INT", "R", "INT", "INT", "RR",…

You can see the data includes both player and team data, where each row is a game by a player.

head(dat)
#>        venue_name match_id match_home_team match_away_team match_date
#> 620384        MCG    15408         Carlton        Richmond 2019-03-21
#> 620385        MCG    15408         Carlton        Richmond 2019-03-21
#> 620386        MCG    15408         Carlton        Richmond 2019-03-21
#> 620387        MCG    15408         Carlton        Richmond 2019-03-21
#> 620388        MCG    15408         Carlton        Richmond 2019-03-21
#> 620389        MCG    15408         Carlton        Richmond 2019-03-21
#>        match_local_time match_attendance match_round match_home_team_goals
#> 620384         19:25:00            85016           1                     9
#> 620385         19:25:00            85016           1                     9
#> 620386         19:25:00            85016           1                     9
#> 620387         19:25:00            85016           1                     9
#> 620388         19:25:00            85016           1                     9
#> 620389         19:25:00            85016           1                     9
#>        match_home_team_behinds match_home_team_score match_away_team_goals
#> 620384                      10                    64                    14
#> 620385                      10                    64                    14
#> 620386                      10                    64                    14
#> 620387                      10                    64                    14
#> 620388                      10                    64                    14
#> 620389                      10                    64                    14
#>        match_away_team_behinds match_away_team_score match_margin match_winner
#> 620384                      13                    97           33     Richmond
#> 620385                      13                    97           33     Richmond
#> 620386                      13                    97           33     Richmond
#> 620387                      13                    97           33     Richmond
#> 620388                      13                    97           33     Richmond
#> 620389                      13                    97           33     Richmond
#>        match_weather_temp_c match_weather_type player_id player_first_name
#> 620384                   25           OVERCAST     12464            Nathan
#> 620385                   25           OVERCAST     12584              Jack
#> 620386                   25           OVERCAST     12341              Kane
#> 620387                   25           OVERCAST     12686              Noah
#> 620388                   25           OVERCAST     11931          Maverick
#> 620389                   25           OVERCAST     11921              Dion
#>        player_last_name player_height_cm player_weight_kg player_is_retired
#> 620384            Broad              192               89             FALSE
#> 620385           Graham              181               82             FALSE
#> 620386          Lambert              178               77             FALSE
#> 620387            Balta              194              100             FALSE
#> 620388           Weller               NA               NA              TRUE
#> 620389          Prestia              175               82             FALSE
#>        player_team guernsey_number kicks marks handballs disposals
#> 620384    Richmond              35     4     1         4         8
#> 620385    Richmond              34    16     7         7        23
#> 620386    Richmond              23    12     7        18        30
#> 620387    Richmond              38     5     2         0         5
#> 620388    Richmond              16     9     2         6        15
#> 620389    Richmond               3    10     1        10        20
#>        effective_disposals disposal_efficiency_percentage goals behinds hitouts
#> 620384                   6                             75     0       0       0
#> 620385                  16                             70     0       1       0
#> 620386                  23                             77     0       1       0
#> 620387                   4                             80     1       0       6
#> 620388                  14                             93     1       1       0
#> 620389                  14                             70     0       0       0
#>        tackles rebounds inside_fifties clearances clangers free_kicks_for
#> 620384       2        2              0          0        2              1
#> 620385       6        0              5          4        6              1
#> 620386       4        1              3          3        4              2
#> 620387       1        0              3          1        5              1
#> 620388       1        2              3          1        1              0
#> 620389       7        0              5          4        2              3
#>        free_kicks_against brownlow_votes contested_possessions
#> 620384                  0              0                     3
#> 620385                  1              0                     9
#> 620386                  0              0                    10
#> 620387                  3              0                     2
#> 620388                  0              0                     4
#> 620389                  0              0                     9
#>        uncontested_possessions contested_marks marks_inside_fifty
#> 620384                       5               0                  0
#> 620385                      15               0                  1
#> 620386                      19               0                  1
#> 620387                       4               0                  0
#> 620388                      11               0                  0
#> 620389                      11               0                  0
#>        one_percenters bounces goal_assists time_on_ground_percentage
#> 620384              6       2            0                        80
#> 620385              2       0            0                        81
#> 620386              0       0            0                        89
#> 620387              2       0            0                        52
#> 620388              2       0            0                        85
#> 620389              1       0            1                        78
#>        afl_fantasy_score supercoach_score centre_clearances stoppage_clearances
#> 620384                32               45                 0                   0
#> 620385               106               88                 2                   2
#> 620386               112               95                 0                   3
#> 620387                29               18                 1                   0
#> 620388                60               63                 0                   1
#> 620389                80               82                 1                   3
#>        score_involvements metres_gained turnovers intercepts
#> 620384                  0           187         1          3
#> 620385                  5           475         5          3
#> 620386                  9           412         4          4
#> 620387                  2           223         2          1
#> 620388                  4           313         3          1
#> 620389                  7           342         3          3
#>        tackles_inside_fifty contest_def_losses contest_def_one_on_ones
#> 620384                    0                  0                       0
#> 620385                    1                  0                       0
#> 620386                    1                  0                       0
#> 620387                    0                  0                       0
#> 620388                    0                  0                       0
#> 620389                    0                  0                       0
#>        contest_off_one_on_ones contest_off_wins def_half_pressure_acts
#> 620384                       0                0                      7
#> 620385                       0                0                     13
#> 620386                       0                0                     10
#> 620387                       2                0                      4
#> 620388                       0                0                      2
#> 620389                       0                0                     13
#>        effective_kicks f50_ground_ball_gets ground_ball_gets
#> 620384               3                    0                2
#> 620385              12                    1                6
#> 620386               7                    0                7
#> 620387               4                    0                0
#> 620388               8                    0                2
#> 620389               7                    2                6
#>        hitouts_to_advantage hitout_win_percentage intercept_marks marks_on_lead
#> 620384                    0                   0.0               0             0
#> 620385                    0                   0.0               1             0
#> 620386                    0                   0.0               1             0
#> 620387                    0                  31.6               1             0
#> 620388                    0                   0.0               0             0
#> 620389                    0                   0.0               0             0
#>        pressure_acts rating_points ruck_contests score_launches shots_at_goal
#> 620384            10           6.1             0              0             0
#> 620385            23           8.7             0              0             1
#> 620386            28          11.5             0              0             2
#> 620387            11           5.1            19              1             2
#> 620388            18          11.8             0              0             2
#> 620389            26          14.5             0              1             0
#>        spoils     subbed player_position
#> 620384      6 Not Subbed             INT
#> 620385      0 Not Subbed             INT
#> 620386      0 Not Subbed               R
#> 620387      0 Not Subbed             INT
#> 620388      0 Not Subbed             INT
#> 620389      0 Not Subbed              RR