fitzRoy R Package

repository·main·Indexed 41 days ago

https://github.com/jimmyday12/fitzroy

An R package providing a consistent API for accessing Australian Football League (AFL) data for Men's and Women's competitions. It includes functions to fetch fixtures, results, ladders, and player statistics in a tidy format, with support for AFLM, AFLW, and experimental support for other competitions like VFL and WAFL.

Tokens
738
Snippets
4
Records
4
Agent score
50%

What's inside fitzRoy

  1. Use the fetch_* functions to retrieve AFL data

    main

    The core API of fitzRoy consists of fetch_* functions that provide a consistent way to access fixtures, lineups, results, ladders, and player statistics. These functions return tidy data suitable for analysis.

    Key functions include:

    • fetch_fixture(season, comp): Retrieves match fixtures.
    • fetch_lineup(season, round_number, comp): Retrieves team lineups.
    • fetch_results(season, round_number, comp): Retrieves match results.
    • fetch_ladder(season, source): Retrieves competition ladders.
    • fetch_player_stats(season, source): Retrieves player statistics.
    • fetch_player_details(team, current, source): Retrieves specific player information.
    fetch_fixture(season = 2020, comp = "AFLM")
    fetch_lineup(season = 2021, round_number = 1, comp = "AFLW")
    fetch_results(season = 2020, round_number = 1, comp = "AFLW")
    fetch_ladder(season = 2020, source = "squiggle")
    fetch_player_stats(season = 2020, source = "fryzigg")
    fetch_player_details(team = "Hawthorn", current = TRUE, source = "AFL")
  2. Install fitzRoy

    main

    You can install the stable version of fitzRoy from CRAN or the development version from GitHub.

    To install the released version:

    install.packages("fitzRoy")

    To install the development version using devtools:

    # install.packages("devtools")
    devtools::install_github("jimmyday12/fitzRoy")
    install.packages("fitzRoy")
  3. Access AFL Women's (AFLW) data

    main

    Since 2019, fitzRoy provides access to AFL Women's data. You can use the standard fetch_* functions by specifying comp = "AFLW", or use specialized functions like get_aflw_match_data().

    Example usage:

    fetch_fixture(season = 2020, comp = "AFLW")
    fetch_results(season = 2020, comp = "AFLW")
    fetch_ladder(season = 2020, comp = "AFLW")
    get_aflw_match_data()
    fetch_fixture(season = 2020, comp = "AFLW")
    fetch_results(season = 2020, comp = "AFLW")
    fetch_ladder(season = 2020, comp = "AFLW")
    get_aflw_match_data()
  4. Access non-AFL competition data

    main

    As an experimental feature, fitzRoy can return data for non-AFL competitions (such as VFL, WAFL, etc.). This currently requires setting source = "AFL".

    Available comp values include:

    • "VFL"
    • "VFLW"
    • "WAFL"
    • "U18B"
    • "U18G"

    Note: Data availability for these competitions may be more limited than for AFLM or AFLW.

    Example usage:

    fetch_fixture(2022, source = "AFL", comp = "VFL")
    fetch_player_stats(2022, round = 1, source = "AFL", comp = "VFLW")
    fetch_fixture(2022, source = "AFL", comp = "WAFL")
    fetch_fixture(2022, source = "AFL", comp = "VFL")
    fetch_player_stats(2022, round = 1, source = "AFL", comp = "VFLW")
    fetch_fixture(2022, source = "AFL", comp = "WAFL")