You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you call cfbd_stats_game_advanced() with a valid value but receive an empty response (e.g., no games yet for 2023), the return value is an empty list. A valid response to the cfbd_stats_game_advanced returns a cfbfastR_data object. For example:
tibble(year = 2021:2023) %>%
mutate(stats = map(year, ~ cfbd_stats_game_advanced(year = .x, season_type = "both")))
2023-04-08 12:49:21:Invalid arguments or no game advanced stats data available!
# A tibble: 3 × 2
year stats
<int> <list>
1 2021 <cfbfstR_ [1,692 × 60]>
2 2022 <cfbfstR_ [2,842 × 60]>
3 2023 <list [0]>
This function does throw a warning -- but in returning objects of different types, it can cause errors in downstream processing that expects objects of the same type. For example, trying to unnest the result above generates a type conflict error:
> tibble(year = 2021:2023) %>%
+ mutate(stats = map(year, ~ cfbd_stats_game_advanced(year = .x, season_type = "both"))) %>%
+ unnest(stats)
2023-04-08 12:52:50:Invalid arguments or no game advanced stats data available!
Error in `list_unchop()`:
! Can't combine `x[[1]]` <tbl_df> and `x[[3]]` <list>.
Expected behavior
The function should either throw an error when no stats are available, or it should return the same object type as a non-empty response (i.e., cfbfastR_data). I suggest returning an empty cfbfastR_data object -- a well-formed query about a valid year (e.g., the current year) in which no games happen to have been played yet should be empty, not an error. In the example above, the correct response gets returned (stats for games in two of the three seasons specified, and none for the last) but the object type conflict prevents their combination in later processing. Expected behavior would look something like this:
tibble(year = 2021:2023) %>%
mutate(stats = map(year, ~ cfbd_stats_game_advanced(year = .x, season_type = "both")))
2023-04-08 12:49:21: Invalid arguments or no game advanced stats data available!
# A tibble: 3 × 2
year stats
<int> <list>
1 2021 <cfbfstR_ [1,692 × 60]>
2 2022 <cfbfstR_ [2,842 × 60]>
3 2023 <cfbfstR_ [0 × 60]>
The text was updated successfully, but these errors were encountered:
When you call
cfbd_stats_game_advanced()
with a valid value but receive an empty response (e.g., no games yet for 2023), the return value is an empty list. A valid response to thecfbd_stats_game_advanced
returns a cfbfastR_data object. For example:This function does throw a warning -- but in returning objects of different types, it can cause errors in downstream processing that expects objects of the same type. For example, trying to unnest the result above generates a type conflict error:
Expected behavior
The function should either throw an error when no stats are available, or it should return the same object type as a non-empty response (i.e., cfbfastR_data). I suggest returning an empty cfbfastR_data object -- a well-formed query about a valid year (e.g., the current year) in which no games happen to have been played yet should be empty, not an error. In the example above, the correct response gets returned (stats for games in two of the three seasons specified, and none for the last) but the object type conflict prevents their combination in later processing. Expected behavior would look something like this:
The text was updated successfully, but these errors were encountered: