AFL Womens Example

The package provides easy access to AFLW data from the AFL.com.au website. This can be accessed via the normal fetch_ functions in the same way you would access Men’s data.

This vignette talks through the main data sources. To fully understand how the fetch_ functions work - please read the Main Fetch Functions vignette.

Fixture

Firstly, we can return the fixture for a season or particular round.

not_cran
online
eval_param
fetch_fixture(season = 2021, comp = "AFLW") %>%
  select(
    compSeason.name, round.name,
    home.team.name, away.team.name,
    venue.name
  )

Lineup

We can get the lineup for a given set of matches in a particular round.

fetch_lineup(2021, round_number = 1, comp = "AFLW") %>%
  select(
    round.name, status, teamName,
    player.playerName.givenName,
    player.playerName.surname, teamStatus
  )

Results

The match results, including the teams playing, venue information and final scores are returned via fetch_results.

fetch_results(2020, round_number = 1, comp = "AFLW") %>%
  select(
    match.date, match.name,
    homeTeamScore.matchScore.totalScore, awayTeamScore.matchScore.totalScore
  )

Ladder

We can also get the ladder at any point with fetch_ladder.

fetch_ladder(2020, round_number = 6, comp = "AFLW") %>%
  select(
    season, round_name,
    position, team.name, played,
    pointsFor, pointsAgainst
  )

Stats

Lastly - we have basic player stats. This will return player level statistics such as possessions, time on ground, fantasy points and a myriad of other statistics.

fetch_player_stats(2020, round_number = 1, comp = "AFLW") %>%
  select(player.player.player.givenName:clearances.totalClearances)

Player Details

We can return player details such as data of birth and listed height and weight.

details_aflw <- fetch_player_details(team = "Western Bulldogs", current = TRUE, comp = "AFLW", source = "AFL")

head(details_aflw)

Coaches Votes

We can also return the coaches votes for a particular season, team or round.

fetch_coaches_votes(season = 2021, round_number = 9, comp = "AFLW", team = "Western Bulldogs")

Legacy/Advanced Stats

We have a legacy function to provide advanced AFLW stats. This is going to be deprecated in favour of a more robust solution but still works for now. The following code should show you how to use those functions. ### Match data

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_afl_cookie()
print(cookie)

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)

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
detailed <- get_aflw_detailed_data(first10_ids)
glimpse(detailed)