Skip to contents

General wrapper for fetching team statistics from a specified source.

Usage

fetch_team_stats(season, summary_type = "totals", source = "afltables", ...)

Arguments

season

Integer. The season to fetch stats for (e.g. 2024).

summary_type

Character. Either "totals" (default) or "averages".

source

Character. Currently only "afltables" is supported.

...

Additional arguments passed to the underlying data source function.

Value

A data frame of team stats for the season.

Examples

fetch_team_stats(2023)
#>  Downloading team stats from AFLTables for 2023
#>  Downloading team stats from AFLTables for 2023 [1.5s]
#> 
#> # A tibble: 18 × 65
#>    season Team      KI_for KI_against MK_for MK_against HB_for HB_against DI_for
#>     <dbl> <chr>      <int>      <int>  <int>      <int>  <int>      <int>  <int>
#>  1   2023 Adelaide    5020       4687   2022       1735   3348       3234   8368
#>  2   2023 Brisbane…   5796       5382   2572       2282   3068       3865   8864
#>  3   2023 Carlton     5765       5515   2444       2317   4025       3814   9790
#>  4   2023 Collingw…   5552       5492   2339       2408   3917       3813   9469
#>  5   2023 Essendon    5026       5074   2321       2305   3559       3438   8585
#>  6   2023 Fremantle   4821       4842   2136       2112   3629       3336   8450
#>  7   2023 Geelong     4847       4932   2102       2122   3099       3311   7946
#>  8   2023 Gold Coa…   5107       4998   2092       2089   2755       3390   7862
#>  9   2023 Greater …   5627       5504   2241       2158   4314       3938   9941
#> 10   2023 Hawthorn    4835       5072   2223       2405   4060       3283   8895
#> 11   2023 Melbourne   5358       5336   2091       2174   3825       3575   9183
#> 12   2023 North Me…   4602       5129   1998       2341   3568       3639   8170
#> 13   2023 Port Ade…   5170       5126   2073       1967   3230       3683   8400
#> 14   2023 Richmond    4896       5144   1948       2160   3286       3367   8182
#> 15   2023 St Kilda    5544       5311   2475       2470   3839       3756   9383
#> 16   2023 Sydney      5151       5038   2038       1854   3465       3524   8616
#> 17   2023 West Coa…   4524       4979   2060       2161   3438       3752   7962
#> 18   2023 Western …   4935       5015   2021       2136   3594       3301   8529
#> # ℹ 56 more variables: DI_against <int>, GL_for <int>, GL_against <int>,
#> #   BH_for <int>, BH_against <int>, HO_for <int>, HO_against <int>,
#> #   TK_for <int>, TK_against <int>, RB_for <int>, RB_against <int>,
#> #   IF_for <int>, IF_against <int>, CL_for <int>, CL_against <int>,
#> #   CG_for <int>, CG_against <int>, FF_for <int>, FF_against <int>,
#> #   BR_for <int>, BR_against <int>, CP_for <int>, CP_against <int>,
#> #   UP_for <int>, UP_against <int>, CM_for <int>, CM_against <int>, …
fetch_team_stats(2024, summary_type = "averages")
#>  Downloading team stats from AFLTables for 2024
#>  Downloading team stats from AFLTables for 2024 [3.9s]
#> 
#> # A tibble: 18 × 66
#>    season Team      KI_for KI_against MK_for MK_against HB_for HB_against DI_for
#>     <dbl> <chr>      <dbl>      <dbl>  <dbl>      <dbl>  <dbl>      <dbl>  <dbl>
#>  1   2024 Adelaide    213        213.   88.0       84.6   148.       138.   361.
#>  2   2024 Brisbane…   233.       199.  110.        82.9   129.       141.   361.
#>  3   2024 Carlton     217.       204.   91.4       86.7   142.       141.   359.
#>  4   2024 Collingw…   204.       220.   81.2       97.8   139.       149.   343.
#>  5   2024 Essendon    221.       213.   98.9       93     159        143.   380.
#>  6   2024 Fremantle   206.       210.   93.1       95.8   161.       137.   367.
#>  7   2024 Geelong     216.       220.   88.0       92.0   135.       144.   350.
#>  8   2024 Gold Coa…   202.       216.   84.7       92.3   145.       145.   347.
#>  9   2024 Greater …   209.       203.   88.3       80.6   164.       141.   373.
#> 10   2024 Hawthorn    210.       207.   91.0       92.4   150.       136.   360.
#> 11   2024 Melbourne   213.       222.   94.2      100.    133        145.   346.
#> 12   2024 North Me…   208.       209.   88.4       91.4   146.       147.   354.
#> 13   2024 Port Ade…   219.       204.   94.8       82.3   126.       138.   345.
#> 14   2024 Richmond    200.       231.   85.3      110.    139.       150.   338.
#> 15   2024 St Kilda    226.       220.  105.       100.    138.       140.   364.
#> 16   2024 Sydney      220        213.   95.5       94.0   136.       140.   356.
#> 17   2024 West Coa…   191.       218.   84.3       98.9   125.       151.   316.
#> 18   2024 Western …   217.       212.   97.5       92.3   154.       141.   371.
#> # ℹ 57 more variables: DI_against <dbl>, GL_for <dbl>, GL_against <dbl>,
#> #   BH_for <dbl>, BH_against <dbl>, HO_for <dbl>, HO_against <dbl>,
#> #   TK_for <dbl>, TK_against <dbl>, RB_for <dbl>, RB_against <dbl>,
#> #   IF_for <dbl>, IF_against <dbl>, CL_for <dbl>, CL_against <dbl>,
#> #   CG_for <dbl>, CG_against <dbl>, FF_for <dbl>, FF_against <dbl>,
#> #   BR_for <dbl>, BR_against <dbl>, CP_for <dbl>, CP_against <dbl>,
#> #   UP_for <dbl>, UP_against <dbl>, CM_for <dbl>, CM_against <dbl>, …