Closed anthonyclissold closed 2 years ago
@anthonyclissold thanks for reporting. I will take a quick look but likely save implementing a fix for this until the end of the season
Hi, any chance this one can be solved. I'm new to coding and don't know how to fix this manually. Thanks for all the work, the package is great!
The issue is that fetch_results_afltables
only pulls the results for the specified round.
Something like this would work - but I don't know if you'd want to make that many requests:
suppressWarnings(if (is.null(match_results_df)) {
match_results_df <- purrr::map_dfr(.x = c(1:round_number),
.f = ~fetch_results_afltables(season, .x))
})
I can make a PR if you like @jimmyday12
@hamgamb that would be great
@GlueSnifter if you don't care about the source of the data, then the other sources work fine for this in the meantime. The AFL Tables data is in a strange format and so requires a bit of extra processing that I haven't got around to doing.
library(fitzRoy)
fetch_ladder(2022, 8, source = "AFL")
#> No encoding supplied: defaulting to UTF-8.
#> # A tibble: 18 × 94
#> season season_name round_name round_number last_updated conference position
#> <dbl> <chr> <chr> <int> <chr> <chr> <int>
#> 1 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 1
#> 2 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 2
#> 3 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 3
#> 4 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 4
#> 5 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 5
#> 6 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 6
#> 7 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 7
#> 8 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 8
#> 9 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 9
#> 10 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 10
#> 11 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 11
#> 12 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 12
#> 13 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 13
#> 14 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 14
#> 15 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 15
#> 16 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 16
#> 17 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 17
#> 18 2022 2022 Toyota … Round 8 8 2022-05-08T… 1 18
#> # … with 87 more variables: played <int>, pointsFor <int>, pointsAgainst <int>,
#> # minScore <int>, maxScore <int>, avgWinMargin <dbl>, avgLossMargin <dbl>,
#> # playersUsed <int>, playedThisRound <lgl>, form <chr>, positionChange <chr>,
#> # team.id <int>, team.providerId <chr>, team.name <chr>,
#> # team.abbreviation <chr>, team.nickname <chr>, team.teamType <chr>,
#> # team.club.id <int>, team.club.providerId <chr>, team.club.name <chr>,
#> # team.club.abbreviation <chr>, team.club.nickname <chr>, …
fetch_ladder(2022, 8, source = "squiggle")
#> ℹ Getting data from https://api.squiggle.com.au/?q=standings;year=2022;round=8
#> ✓ Getting data from https://api.squiggle.com.au/?q=standings;year=2022;round=8 …
#>
#> # A tibble: 18 × 15
#> for. draws played behinds_for goals_against rank goals_for behinds_against
#> <int> <int> <int> <int> <int> <int> <int> <int>
#> 1 726 0 8 96 69 1 105 75
#> 2 703 0 8 91 66 2 102 63
#> 3 851 0 8 77 80 3 129 82
#> 4 725 0 8 89 95 4 106 81
#> 5 754 0 8 112 89 5 107 63
#> 6 745 0 8 79 90 6 111 89
#> 7 670 0 8 94 82 7 96 79
#> 8 782 0 8 80 93 8 117 113
#> 9 752 0 8 86 108 9 111 69
#> 10 666 0 8 90 95 10 96 79
#> 11 590 0 8 98 87 11 82 80
#> 12 666 0 8 84 104 12 97 94
#> 13 631 0 8 85 103 13 91 84
#> 14 621 0 8 75 109 14 91 97
#> 15 563 0 8 89 103 15 79 87
#> 16 640 0 8 88 122 16 92 85
#> 17 475 0 8 55 125 17 70 105
#> 18 450 0 8 54 128 18 66 97
#> # … with 7 more variables: id <int>, against <int>, percentage <dbl>,
#> # wins <int>, name <chr>, losses <int>, pts <int>
Created on 2022-05-16 by the reprex package (v2.0.1)
Thank you very much guys, @hamgamb's solution worked but I ended up using: fitzRoy::return_ladder(season = 1897:2022) and then messing around with the resultant table to get what I wanted.
It appears that there is an issue importing the ladder info from AFL tables into R. The data only appears to be calculated on the data for the selected round.
See the following example from 2021 R22:
AFL Tables:
FitzRoy: