NOTE - The AFL website for Women’s data has been taken down. This page is left for posterity however these functions no longer work.

Match data

library(fitzRoy)
library(dplyr)

A good thing to check is that the cookie is working. Often this gets changed or moved and without it, the code won’t work.

cookie <- get_aflw_cookie()

print(cookie)
#> [1] "edd7fd3e4a7fdcc1d4ef14ebfa81355a"

Note - if this is NULL the rest of this Vignette won’t show any outputs but the code will remain!

We can use the get_aflw_match_data() function to retrieve match data for all matches.

match_data <- get_aflw_match_data()

Note that there will be warnings if a fixture is available but no match data has been added yet. If this is the case, make sure you don’t try to request detailed match stats for these match IDs.

glimpse(match_data)
#> Rows: 142
#> Columns: 30
#> $ Match.Id             <chr> "CD_M20172640101", "CD_M20172640102", "CD_M20172…
#> $ Round.Id             <chr> "CD_R201726401", "CD_R201726401", "CD_R201726401…
#> $ Competition.Id       <chr> "CD_S2017264", "CD_S2017264", "CD_S2017264", "CD…
#> $ Venue                <chr> "Ikon Park", "Thebarton Oval", "Victoria Univers…
#> $ Local.Start.Time     <dttm> 2017-02-03 19:45:00, 2017-02-04 16:35:00, 2017-…
#> $ Round.Number         <int> 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, …
#> $ Round.Abbreviation   <chr> "Rd 1", "Rd 1", "Rd 1", "Rd 1", "Rd 2", "Rd 2", …
#> $ Weather.Type         <chr> "CLEAR_NIGHT", "RAIN", "RAIN", "RAIN", "CLEAR_NI…
#> $ Weather.Description  <chr> "Clear", "Rain at times", "Partly cloudy", "Rain…
#> $ Temperature          <dbl> 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, …
#> $ Home.Team            <chr> "Carlton", "Adelaide Crows", "Western Bulldogs",…
#> $ Home.Goals           <int> 7, 7, 6, 1, 2, 7, 4, 3, 7, 4, 4, 2, 6, 6, 3, 3, …
#> $ Home.Behinds         <int> 4, 6, 8, 4, 11, 5, 1, 5, 1, 3, 5, 5, 6, 7, 7, 5,…
#> $ Home.Points          <int> 46, 48, 44, 10, 23, 47, 25, 23, 43, 27, 29, 17, …
#> $ Home.Left.Behinds    <int> 1, 2, 2, 1, 2, 1, 0, 0, 0, 0, 3, 2, 2, 5, 3, 3, …
#> $ Home.Right.Behinds   <int> 2, 2, 4, 2, 5, 2, 1, 1, 0, 2, 1, 0, 2, 1, 3, 2, …
#> $ Home.Left.Posters    <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, …
#> $ Home.Right.Posters   <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, …
#> $ Home.Rushed.Behinds  <int> 1, 2, 2, 1, 3, 2, 0, 2, 1, 1, 0, 3, 1, 1, 1, 0, …
#> $ Home.Touched.Behinds <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
#> $ Away.Team            <chr> "Collingwood", "GWS Giants", "Fremantle", "Brisb…
#> $ Away.Goals           <int> 1, 1, 1, 4, 7, 5, 7, 5, 6, 3, 6, 2, 5, 1, 5, 6, …
#> $ Away.Behinds         <int> 5, 6, 6, 1, 6, 4, 2, 6, 7, 5, 7, 2, 6, 3, 2, 10,…
#> $ Away.Points          <int> 11, 12, 12, 25, 48, 34, 44, 36, 43, 23, 43, 14, …
#> $ Away.Left.Behinds    <int> 0, 1, 2, 1, 2, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 3, …
#> $ Away.Right.Behinds   <int> 3, 4, 3, 0, 2, 3, 1, 3, 3, 3, 5, 1, 1, 1, 2, 4, …
#> $ Away.Left.Posters    <int> 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 2, 1, 0, 1, …
#> $ Away.Right.Posters   <int> 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, …
#> $ Away.Rushed.Behinds  <int> 1, 1, 1, 0, 2, 1, 0, 1, 2, 1, 0, 0, 2, 0, 0, 2, …
#> $ Away.Touched.Behinds <int> 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, …

Detailed stats

The get_aflw_detailed_data() can be used to return more detailed data than the match data shown above. It takes a vector of match IDs as an argument. For example, let’s say we want detailed stats for the first 10 games in match_data above. Then we would do:

first10 <- head(match_data, 10)
first10_ids <- first10$Match.Id
first10_ids
#>  [1] "CD_M20172640101" "CD_M20172640102" "CD_M20172640103" "CD_M20172640104"
#>  [5] "CD_M20172640201" "CD_M20172640202" "CD_M20172640203" "CD_M20172640204"
#>  [9] "CD_M20172640301" "CD_M20172640302"
detailed <- get_aflw_detailed_data(first10_ids)
#> Warning: `funs()` is deprecated as of dplyr 0.8.0.
#> Please use a list of either functions or lambdas: 
#> 
#>   # Simple named list: 
#>   list(mean = mean, median = median)
#> 
#>   # Auto named with `tibble::lst()`: 
#>   tibble::lst(mean, median)
#> 
#>   # Using lambdas
#>   list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
glimpse(detailed)
#> Rows: 10
#> Columns: 191
#> $ Match.Id                                                    <chr> "CD_M2017…
#> $ Round.Id                                                    <chr> "CD_R2017…
#> $ Competition.Id                                              <chr> "CD_S2017…
#> $ away.stats.averages.behinds                                 <dbl> 4.1, 2.1,…
#> $ away.stats.averages.bounces                                 <dbl> 3.7, 1.9,…
#> $ away.stats.averages.clangers                                <dbl> 39.7, 35.…
#> $ away.stats.averages.clearances.centreClearances             <dbl> 4.9, 5.7,…
#> $ away.stats.averages.clearances.stoppageClearances           <dbl> 16.9, 16.…
#> $ away.stats.averages.clearances.totalClearances              <dbl> 21.7, 22.…
#> $ away.stats.averages.contestedMarks                          <dbl> 6.3, 3.0,…
#> $ away.stats.averages.contestedPossessions                    <dbl> 90.3, 85.…
#> $ away.stats.averages.disposalEfficiency                      <dbl> 56.6, 54.…
#> $ away.stats.averages.disposals                               <dbl> 167.6, 15…
#> $ away.stats.averages.dreamTeamPoints                         <dbl> 843.3, 75…
#> $ away.stats.averages.freesAgainst                            <dbl> 13.6, 13.…
#> $ away.stats.averages.freesFor                                <dbl> 15.6, 14.…
#> $ away.stats.averages.goalAccuracy                            <dbl> 45.7, 43.…
#> $ away.stats.averages.goalAssists                             <dbl> 2.6, 2.1,…
#> $ away.stats.averages.goalEfficiency                          <dbl> 19.5, 18.…
#> $ away.stats.averages.goals                                   <dbl> 4.6, 3.3,…
#> $ away.stats.averages.handballs                               <dbl> 47.9, 50.…
#> $ away.stats.averages.hitouts                                 <dbl> 36.6, 28.…
#> $ away.stats.averages.inside50s                               <dbl> 23.4, 18.…
#> $ away.stats.averages.intercepts                              <dbl> 45.3, 42.…
#> $ away.stats.averages.interchangeCounts.interchangeCap        <dbl> 999, 999,…
#> $ away.stats.averages.interchangeCounts.interchangeCountQ1    <dbl> 16, 9, 0,…
#> $ away.stats.averages.interchangeCounts.interchangeCountQ2    <dbl> 14, 21, 2…
#> $ away.stats.averages.interchangeCounts.interchangeCountQ3    <dbl> 0, 13, 4,…
#> $ away.stats.averages.interchangeCounts.interchangeCountQ4    <dbl> 0, 11, 0,…
#> $ away.stats.averages.interchangeCounts.totalInterchangeCount <dbl> 30, 54, 3…
#> $ away.stats.averages.kicks                                   <dbl> 119.7, 10…
#> $ away.stats.averages.lastUpdated                             <dttm> 2017-03-…
#> $ away.stats.averages.marks                                   <dbl> 39.7, 29.…
#> $ away.stats.averages.marksInside50                           <dbl> 6.0, 4.4,…
#> $ away.stats.averages.metresGained                            <dbl> NA, NA, N…
#> $ away.stats.averages.onePercenters                           <dbl> 21.6, 18.…
#> $ away.stats.averages.ranking                                 <dbl> NA, NA, N…
#> $ away.stats.averages.ratingPoints                            <dbl> NA, NA, N…
#> $ away.stats.averages.rebound50s                              <dbl> 18.7, 22.…
#> $ away.stats.averages.scoreInvolvements                       <dbl> NA, NA, N…
#> $ away.stats.averages.shotEfficiency                          <dbl> 42.7, 42.…
#> $ away.stats.averages.shotsAtGoal                             <dbl> 10.0, 7.6…
#> $ away.stats.averages.superGoals                              <dbl> NA, NA, N…
#> $ away.stats.averages.tackles                                 <dbl> 56.6, 55.…
#> $ away.stats.averages.tacklesInside50                         <dbl> 7.7, 5.0,…
#> $ away.stats.averages.totalPossessions                        <dbl> 168.9, 15…
#> $ away.stats.averages.turnovers                               <dbl> 47.7, 48.…
#> $ away.stats.averages.uncontestedPossessions                  <dbl> 78.6, 68.…
#> $ away.stats.totals.behinds                                   <dbl> 5, 6, 6, …
#> $ away.stats.totals.bounces                                   <dbl> 3, 0, 4, …
#> $ away.stats.totals.clangers                                  <dbl> 37, 45, 3…
#> $ away.stats.totals.clearances.centreClearances               <dbl> 4, 7, 3, …
#> $ away.stats.totals.clearances.stoppageClearances             <dbl> 15, 13, 1…
#> $ away.stats.totals.clearances.totalClearances                <dbl> 19, 20, 1…
#> $ away.stats.totals.contestedMarks                            <dbl> 4, 2, 2, …
#> $ away.stats.totals.contestedPossessions                      <dbl> 94, 92, 7…
#> $ away.stats.totals.disposalEfficiency                        <dbl> 52.8, 46.…
#> $ away.stats.totals.disposals                                 <dbl> 163, 165,…
#> $ away.stats.totals.dreamTeamPoints                           <dbl> 926, 783,…
#> $ away.stats.totals.freesAgainst                              <dbl> 9, 21, 17…
#> $ away.stats.totals.freesFor                                  <dbl> 20, 23, 1…
#> $ away.stats.totals.goalAccuracy                              <dbl> 16.7, 10.…
#> $ away.stats.totals.goalAssists                               <dbl> 0, 1, 1, …
#> $ away.stats.totals.goalEfficiency                            <dbl> 3.7, 4.8,…
#> $ away.stats.totals.goals                                     <dbl> 1, 1, 1, …
#> $ away.stats.totals.handballs                                 <dbl> 48, 52, 5…
#> $ away.stats.totals.hitouts                                   <dbl> 28, 9, 14…
#> $ away.stats.totals.inside50s                                 <dbl> 27, 21, 1…
#> $ away.stats.totals.intercepts                                <dbl> 48, 52, 5…
#> $ away.stats.totals.interchangeCounts.interchangeCap          <dbl> 0, 0, 0, …
#> $ away.stats.totals.interchangeCounts.interchangeCountQ1      <dbl> 0, 0, 0, …
#> $ away.stats.totals.interchangeCounts.interchangeCountQ2      <dbl> 0, 0, 0, …
#> $ away.stats.totals.interchangeCounts.interchangeCountQ3      <dbl> 0, 0, 0, …
#> $ away.stats.totals.interchangeCounts.interchangeCountQ4      <dbl> 0, 0, 0, …
#> $ away.stats.totals.interchangeCounts.totalInterchangeCount   <dbl> 0, 0, 0, …
#> $ away.stats.totals.kicks                                     <dbl> 115, 113,…
#> $ away.stats.totals.lastUpdated                               <dttm> 2017-02-…
#> $ away.stats.totals.marks                                     <dbl> 35, 37, 3…
#> $ away.stats.totals.marksInside50                             <dbl> 4, 6, 3, …
#> $ away.stats.totals.metresGained                              <dbl> NA, NA, N…
#> $ away.stats.totals.onePercenters                             <dbl> 23, 13, 2…
#> $ away.stats.totals.ranking                                   <dbl> NA, NA, N…
#> $ away.stats.totals.ratingPoints                              <dbl> NA, NA, N…
#> $ away.stats.totals.rebound50s                                <dbl> 18, 15, 2…
#> $ away.stats.totals.scoreInvolvements                         <dbl> NA, NA, N…
#> $ away.stats.totals.shotEfficiency                            <dbl> 22.2, 47.…
#> $ away.stats.totals.shotsAtGoal                               <dbl> 6, 10, 8,…
#> $ away.stats.totals.superGoals                                <dbl> NA, NA, N…
#> $ away.stats.totals.tackles                                   <dbl> 87, 62, 4…
#> $ away.stats.totals.tacklesInside50                           <dbl> 8, 9, 2, …
#> $ away.stats.totals.totalPossessions                          <dbl> 163, 169,…
#> $ away.stats.totals.turnovers                                 <dbl> 57, 55, 4…
#> $ away.stats.totals.uncontestedPossessions                    <dbl> 69, 77, 7…
#> $ away.team.teamAbbr                                          <chr> "COLL", "…
#> $ away.team.teamId                                            <chr> "CD_T8097…
#> $ away.team.teamName                                          <chr> "Collingw…
#> $ away.team.teamNickname                                      <chr> "Magpies"…
#> $ home.stats.averages.behinds                                 <dbl> 2.7, 4.8,…
#> $ home.stats.averages.bounces                                 <dbl> 2.1, 1.6,…
#> $ home.stats.averages.clangers                                <dbl> 38.7, 43.…
#> $ home.stats.averages.clearances.centreClearances             <dbl> 4.4, 4.8,…
#> $ home.stats.averages.clearances.stoppageClearances           <dbl> 15.7, 15.…
#> $ home.stats.averages.clearances.totalClearances              <dbl> 20.1, 19.…
#> $ home.stats.averages.contestedMarks                          <dbl> 7.4, 5.8,…
#> $ home.stats.averages.contestedPossessions                    <dbl> 96.1, 108…
#> $ home.stats.averages.disposalEfficiency                      <dbl> 59.6, 54.…
#> $ home.stats.averages.disposals                               <dbl> 172.0, 18…
#> $ home.stats.averages.dreamTeamPoints                         <dbl> 784.7, 85…
#> $ home.stats.averages.freesAgainst                            <dbl> 14.1, 15.…
#> $ home.stats.averages.freesFor                                <dbl> 11.9, 19.…
#> $ home.stats.averages.goalAccuracy                            <dbl> 50.6, 36.…
#> $ home.stats.averages.goalAssists                             <dbl> 3.3, 2.4,…
#> $ home.stats.averages.goalEfficiency                          <dbl> 23.8, 17.…
#> $ home.stats.averages.goals                                   <dbl> 5.6, 5.6,…
#> $ home.stats.averages.handballs                               <dbl> 60.6, 57.…
#> $ home.stats.averages.hitouts                                 <dbl> 27.9, 23.…
#> $ home.stats.averages.inside50s                               <dbl> 23.4, 32.…
#> $ home.stats.averages.intercepts                              <dbl> 51.0, 57.…
#> $ home.stats.averages.interchangeCounts.interchangeCap        <dbl> 999, 0, 9…
#> $ home.stats.averages.interchangeCounts.interchangeCountQ1    <dbl> 4, 0, 8, …
#> $ home.stats.averages.interchangeCounts.interchangeCountQ2    <dbl> 4, 0, 21,…
#> $ home.stats.averages.interchangeCounts.interchangeCountQ3    <dbl> 0, 0, 1, …
#> $ home.stats.averages.interchangeCounts.interchangeCountQ4    <dbl> 0, 0, 0, …
#> $ home.stats.averages.interchangeCounts.totalInterchangeCount <dbl> 8, 0, 30,…
#> $ home.stats.averages.kicks                                   <dbl> 111.4, 13…
#> $ home.stats.averages.lastUpdated                             <dttm> 2017-03-…
#> $ home.stats.averages.marks                                   <dbl> 32.7, 31.…
#> $ home.stats.averages.marksInside50                           <dbl> 6.4, 6.9,…
#> $ home.stats.averages.metresGained                            <dbl> NA, NA, N…
#> $ home.stats.averages.onePercenters                           <dbl> 19.7, 20.…
#> $ home.stats.averages.ranking                                 <dbl> NA, NA, N…
#> $ home.stats.averages.ratingPoints                            <dbl> NA, NA, N…
#> $ home.stats.averages.rebound50s                              <dbl> 22.0, 17.…
#> $ home.stats.averages.scoreInvolvements                       <dbl> NA, NA, N…
#> $ home.stats.averages.shotEfficiency                          <dbl> 47.0, 47.…
#> $ home.stats.averages.shotsAtGoal                             <dbl> 11.0, 15.…
#> $ home.stats.averages.superGoals                              <dbl> NA, NA, N…
#> $ home.stats.averages.tackles                                 <dbl> 49.4, 55.…
#> $ home.stats.averages.tacklesInside50                         <dbl> 8.7, 11.4…
#> $ home.stats.averages.totalPossessions                        <dbl> 173.4, 18…
#> $ home.stats.averages.turnovers                               <dbl> 50.0, 55.…
#> $ home.stats.averages.uncontestedPossessions                  <dbl> 77.3, 76.…
#> $ home.stats.totals.behinds                                   <dbl> 4, 6, 8, …
#> $ home.stats.totals.bounces                                   <dbl> 4, 0, 5, …
#> $ home.stats.totals.clangers                                  <dbl> 44, 46, 2…
#> $ home.stats.totals.clearances.centreClearances               <dbl> 1, 5, 6, …
#> $ home.stats.totals.clearances.stoppageClearances             <dbl> 16, 9, 24…
#> $ home.stats.totals.clearances.totalClearances                <dbl> 17, 14, 3…
#> $ home.stats.totals.contestedMarks                            <dbl> 7, 5, 1, …
#> $ home.stats.totals.contestedPossessions                      <dbl> 106, 108,…
#> $ home.stats.totals.disposalEfficiency                        <dbl> 60.6, 51.…
#> $ home.stats.totals.disposals                                 <dbl> 198, 185,…
#> $ home.stats.totals.dreamTeamPoints                           <dbl> 847, 825,…
#> $ home.stats.totals.freesAgainst                              <dbl> 20, 23, 1…
#> $ home.stats.totals.freesFor                                  <dbl> 9, 21, 17…
#> $ home.stats.totals.goalAccuracy                              <dbl> 58.3, 46.…
#> $ home.stats.totals.goalAssists                               <dbl> 4, 3, 6, …
#> $ home.stats.totals.goalEfficiency                            <dbl> 28.0, 30.…
#> $ home.stats.totals.goals                                     <dbl> 7, 7, 6, …
#> $ home.stats.totals.handballs                                 <dbl> 86, 66, 8…
#> $ home.stats.totals.hitouts                                   <dbl> 30, 23, 3…
#> $ home.stats.totals.inside50s                                 <dbl> 25, 23, 2…
#> $ home.stats.totals.intercepts                                <dbl> 56, 56, 4…
#> $ home.stats.totals.interchangeCounts.interchangeCap          <dbl> 0, 0, 0, …
#> $ home.stats.totals.interchangeCounts.interchangeCountQ1      <dbl> 0, 0, 0, …
#> $ home.stats.totals.interchangeCounts.interchangeCountQ2      <dbl> 0, 0, 0, …
#> $ home.stats.totals.interchangeCounts.interchangeCountQ3      <dbl> 0, 0, 0, …
#> $ home.stats.totals.interchangeCounts.interchangeCountQ4      <dbl> 0, 0, 0, …
#> $ home.stats.totals.interchangeCounts.totalInterchangeCount   <dbl> 0, 0, 0, …
#> $ home.stats.totals.kicks                                     <dbl> 112, 119,…
#> $ home.stats.totals.lastUpdated                               <dttm> 2017-02-…
#> $ home.stats.totals.marks                                     <dbl> 26, 31, 2…
#> $ home.stats.totals.marksInside50                             <dbl> 6, 8, 7, …
#> $ home.stats.totals.metresGained                              <dbl> NA, NA, N…
#> $ home.stats.totals.onePercenters                             <dbl> 15, 15, 2…
#> $ home.stats.totals.ranking                                   <dbl> NA, NA, N…
#> $ home.stats.totals.ratingPoints                              <dbl> NA, NA, N…
#> $ home.stats.totals.rebound50s                                <dbl> 25, 19, 1…
#> $ home.stats.totals.scoreInvolvements                         <dbl> NA, NA, N…
#> $ home.stats.totals.shotEfficiency                            <dbl> 48.0, 65.…
#> $ home.stats.totals.shotsAtGoal                               <dbl> 12, 15, 1…
#> $ home.stats.totals.superGoals                                <dbl> NA, NA, N…
#> $ home.stats.totals.tackles                                   <dbl> 59, 55, 5…
#> $ home.stats.totals.tacklesInside50                           <dbl> 15, 9, 13…
#> $ home.stats.totals.totalPossessions                          <dbl> 197, 186,…
#> $ home.stats.totals.turnovers                                 <dbl> 47, 52, 4…
#> $ home.stats.totals.uncontestedPossessions                    <dbl> 91, 78, 9…
#> $ home.team.teamAbbr                                          <chr> "CARL", "…
#> $ home.team.teamId                                            <chr> "CD_T8096…
#> $ home.team.teamName                                          <chr> "Carlton"…
#> $ home.team.teamNickname                                      <chr> "Blues", …