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
Hi! I can't make out if it is possible to output predictions for the game by date, and not by entering individual commands? It would be cool if you could enter "20240111" into the "cbbdata::cbd_torvik_game_prediction" function and get a prediction of the games for all the games of all the teams for that day.
The text was updated successfully, but these errors were encountered:
@barjehkopaxum not that difficult to put together some basic script that will achieve this for you, for example you could run:
# Load required library or install it if it's not available
if (!requireNamespace("cbbdata", quietly = TRUE)) {
install.packages("cbbdata")
}
# Generate predictions for today's games
# Load the future games schedule
schedule <- cbd_torvik_season_schedule(year = 2024)
# Convert the 'date' column to Date class and filter for future games
todays_games <- schedule %>%
dplyr::mutate(date = as.Date(date)) %>%
filter(date == Sys.Date())
todays_predictions <- list()
for (i in seq_len(nrow(todays_games))) {
game <- todays_games[i, ]
game_location <- if (game$neutral) "N" else "H"
# Format the date to the required format YYYYMMDD
game_date <- format(as.Date(game$date), "%Y%m%d")
tryCatch({
prediction <- cbd_torvik_game_prediction(
team = game$home,
opp = game$away,
date = game_date,
location = game_location
)
# Add the game_id to the prediction tibble/df
prediction$game_id <- game$game_id
todays_predictions[[i]] <- prediction
}, error=function(e) {
cat("Error in processing prediction for game_id", game$game_id, ":", e$message, "\n")
})
}
# Combine predictions into a single data frame
todays_predictions <- do.call(rbind, todays_predictions)
# Order the predictions by game_id if needed
todays_predictions <- todays_predictions[order(todays_predictions$game_id), ]
Hi! I can't make out if it is possible to output predictions for the game by date, and not by entering individual commands? It would be cool if you could enter "20240111" into the "cbbdata::cbd_torvik_game_prediction" function and get a prediction of the games for all the games of all the teams for that day.
The text was updated successfully, but these errors were encountered: