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] "1e332209e0431b20f7f06b5a1099782a"

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

We can use the fetch_results() function to retrieve match data matches.

match_data <- fetch_results(2020, round_number = 1, comp = "AFLW")

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: 7
#> Columns: 75
#> $ match.name                          <chr> "Richmond Vs Carlton", "GWS Giant…
#> $ match.date                          <dttm> 2020-02-07 08:45:00, 2020-02-08 …
#> $ match.status                        <chr> "CONCLUDED", "CONCLUDED", "CONCLU…
#> $ match.matchId                       <chr> "CD_M20202640101", "CD_M202026401…
#> $ match.venue                         <chr> "CD_V50", "CD_V402", "CD_V371", "…
#> $ match.utcStartTime                  <chr> "2020-02-07T08:45:00", "2020-02-0…
#> $ match.homeTeamId                    <chr> "CD_T8788", "CD_T7889", "CD_T7386…
#> $ match.awayTeamId                    <chr> "CD_T8096", "CD_T8786", "CD_T8466…
#> $ match.round                         <chr> "CD_R202026401", "CD_R202026401",…
#> $ match.venueLocalStartTime           <chr> "2020-02-07T19:45:00", "2020-02-0…
#> $ match.abbr                          <chr> "RICH V CARL", "GWS V GCFC", "MEL…
#> $ match.twitterHashTag                <chr> "#AFLWTigersBlues", "#AFLWGiantsS…
#> $ match.homeTeam.name                 <chr> "Richmond", "GWS Giants", "Melbou…
#> $ match.homeTeam.timeZone             <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ match.homeTeam.teamId               <chr> "CD_T8788", "CD_T7889", "CD_T7386…
#> $ match.homeTeam.abbr                 <chr> "RICH", "GWS", "MELB", "BL", "COL…
#> $ match.homeTeam.nickname             <chr> "Richmond", "Giants", "Demons", "…
#> $ match.awayTeam.name                 <chr> "Carlton", "Gold Coast Suns", "Ka…
#> $ match.awayTeam.timeZone             <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ match.awayTeam.teamId               <chr> "CD_T8096", "CD_T8786", "CD_T8466…
#> $ match.awayTeam.abbr                 <chr> "CARL", "GCFC", "NMFC", "ADEL", "…
#> $ match.awayTeam.nickname             <chr> "Blues", "Suns", "Kangaroos", "Cr…
#> $ venue.address                       <chr> "Melbourne", "Sydney", "Melbourne…
#> $ venue.name                          <chr> "Ikon Park", "Blacktown Internati…
#> $ venue.state                         <chr> "VIC", "NSW", "VIC", "QLD", "VIC"…
#> $ venue.timeZone                      <chr> "Australia/Melbourne", "Australia…
#> $ venue.venueId                       <chr> "CD_V50", "CD_V402", "CD_V371", "…
#> $ venue.abbreviation                  <chr> "IKP", "BISP", "CAS", "HP", "VIPC…
#> $ venue.capacity                      <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ venue.groundDimension               <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ venue.latitude                      <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ venue.longitude                     <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ round.name                          <chr> "Round 1", "Round 1", "Round 1", …
#> $ round.year                          <chr> "2020", "2020", "2020", "2020", "…
#> $ round.roundId                       <chr> "CD_R202026401", "CD_R202026401",…
#> $ round.abbreviation                  <chr> "Rd 1", "Rd 1", "Rd 1", "Rd 1", "…
#> $ round.competitionId                 <chr> "CD_S2020264", "CD_S2020264", "CD…
#> $ round.roundNumber                   <int> 1, 1, 1, 1, 1, 1, 1
#> $ status                              <chr> "CONCLUDED", "CONCLUDED", "CONCLU…
#> $ matchId                             <chr> "CD_M20202640101", "CD_M202026401…
#> $ scoreWorm                           <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ scoreMap                            <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ lastUpdated                         <chr> "2020-02-07T11:04:44.540+0000", "…
#> $ homeTeamScore.periodScore           <list> [<data.frame[4 x 5]>, <data.fram…
#> $ homeTeamScore.rushedBehinds         <int> 0, 0, 0, 1, 0, 0, 2
#> $ homeTeamScore.minutesInFront        <int> 0, 9, 12, 56, 39, 0, 37
#> $ homeTeamScore.matchScore.totalScore <int> 14, 9, 22, 34, 38, 14, 44
#> $ homeTeamScore.matchScore.goals      <int> 2, 1, 3, 5, 5, 2, 6
#> $ homeTeamScore.matchScore.behinds    <int> 2, 3, 4, 4, 8, 2, 8
#> $ homeTeamScore.matchScore.superGoals <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ awayTeamScore.periodScore           <list> [<data.frame[4 x 5]>, <data.fram…
#> $ awayTeamScore.rushedBehinds         <int> 4, 0, 0, 3, 0, 0, 3
#> $ awayTeamScore.minutesInFront        <int> 56, 23, 29, 0, 20, 60, 10
#> $ awayTeamScore.matchScore.totalScore <int> 48, 8, 20, 21, 11, 39, 28
#> $ awayTeamScore.matchScore.goals      <int> 6, 1, 3, 3, 1, 6, 4
#> $ awayTeamScore.matchScore.behinds    <int> 12, 2, 2, 3, 5, 3, 4
#> $ awayTeamScore.matchScore.superGoals <lgl> NA, NA, NA, NA, NA, NA, NA
#> $ matchClock.periods                  <list> [<data.frame[4 x 5]>, <data.fram…
#> $ weather.description                 <chr> "Humid Partly cloudy", "Rain, hea…
#> $ weather.tempInCelsius               <dbl> 26, 21, 28, 18, 26, 26, 18
#> $ weather.weatherType                 <chr> "OVERCAST", "RAIN", "OVERCAST", "…
#> $ homeTeamScoreChart.goals            <int> 2, 1, 3, 5, 5, 2, 6
#> $ homeTeamScoreChart.leftBehinds      <int> 1, 2, 3, 1, 3, 0, 2
#> $ homeTeamScoreChart.rightBehinds     <int> 1, 1, 1, 1, 3, 2, 4
#> $ homeTeamScoreChart.leftPosters      <int> 0, 0, 0, 0, 1, 0, 0
#> $ homeTeamScoreChart.rightPosters     <int> 0, 0, 0, 1, 1, 0, 0
#> $ homeTeamScoreChart.rushedBehinds    <int> 0, 0, 0, 1, 0, 0, 2
#> $ homeTeamScoreChart.touchedBehinds   <int> 0, 0, 0, 0, 0, 0, 0
#> $ awayTeamScoreChart.goals            <int> 6, 1, 3, 3, 1, 6, 4
#> $ awayTeamScoreChart.leftBehinds      <int> 3, 1, 1, 0, 1, 2, 0
#> $ awayTeamScoreChart.rightBehinds     <int> 3, 1, 1, 0, 4, 0, 1
#> $ awayTeamScoreChart.leftPosters      <int> 0, 0, 0, 0, 0, 1, 0
#> $ awayTeamScoreChart.rightPosters     <int> 1, 0, 0, 0, 0, 0, 0
#> $ awayTeamScoreChart.rushedBehinds    <int> 4, 0, 0, 3, 0, 0, 3
#> $ awayTeamScoreChart.touchedBehinds   <int> 1, 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
#> NULL
detailed <- get_aflw_detailed_data(first10_ids)
#> Warning: 'get_aflw_cookie' is deprecated.
#> Use 'get_afl_cookie' instead.
#> See help("Deprecated")
glimpse(detailed)
#> Rows: 0
#> Columns: 0