I’m pleased to announce that fitzRoy v1.4.0 has just been accepted to CRAN!
This update mostly contains bug fixes. You can read about them below.
New Features
Squiggle API is now more flexible
The function to call the Squiggle API is now more flexible and should allow for any new queries that are added to the Squiggle API to be used. Previously many of the queries and optional arguments were hardcode but these are now simply sent to the API as is, and the API will return data accordingly. You can read about the API here and provide any of the main “query” types to the first argument, with additional optional parameters being named arguments you can supply.
As a general rule
Invalid query types will return an error
Invalid optional argument types will be ignored and API data returned based on other arguments
Optional arguments with nonsensical values will generally return an empty data frame
Previously all of these situations returned an unhelpful error.
# Return a list of the sources, with ID'sfitzRoy::fetch_squiggle_data("sources")
ℹ Getting data from https://api.squiggle.com.au?q=sources&format=JSON
✔ Getting data from https://api.squiggle.com.au?q=sources&format=JSON [1.3s]
# Provide an incorrect queryfitzRoy::fetch_squiggle_data(query ="fitzRoy")
ℹ Getting data from https://api.squiggle.com.au?q=fitzRoy&format=JSON
Error in `fitzRoy::fetch_squiggle_data()`:
! API did not return any data
ℹ Did you check that the queries provided are valid?
✖ You've supplied the following queries: "q"
✖ Getting data from https://api.squiggle.com.au?q=fitzRoy&format=JSON [447ms]
# Provide an invalid optional argumentfitzRoy::fetch_squiggle_data(query ="tips", fitzRoy =TRUE, source =1, year =2024)
ℹ Getting data from https://api.squiggle.com.au?q=tips&fitzRoy=TRUE&source=1&ye…
✔ Getting data from https://api.squiggle.com.au?q=tips&fitzRoy=TRUE&source=1&ye…
# Provide an incorrect optional argument valuefitzRoy::fetch_squiggle_data(query ="tips", fitzRoy =TRUE, source =1, year =2030)
ℹ Getting data from https://api.squiggle.com.au?q=tips&fitzRoy=TRUE&source=1&ye…
✔ Getting data from https://api.squiggle.com.au?q=tips&fitzRoy=TRUE&source=1&ye…
# A tibble: 0 × 0
replace_teams now handle indigenous names
With teams starting to use indigenous names during Sir Doug Nicholls rounds, the AFL API was returning these names over the traditional team names, which was causing errors in places. Most people were handling this in their own code, or using teamIds, but where the package was using replace_names function, we’ve added a check to ensure we can match the indigenous and traditional name together.
fitzRoy::replace_teams("Narrm")
[1] "Melbourne"
fitzRoy::replace_teams("Walyalup")
[1] "Fremantle"
Bug Fixes
Handle “Opening Round” fixtures for a bunch of functions that were breaking
Fixed a bug where fetch_player_details was failing for certain teams
Handled situations where an ‘unused sub’ was causing issues on various Footywire functions