diff --git a/DESCRIPTION b/DESCRIPTION index 04da5477..d2cf4a0e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cfbfastR Title: Functions to Access College Football Play by Play Data -Version: 1.1.0 +Version: 1.2.0 Authors@R: c(person(given = "Saiem", family = "Gilani", diff --git a/NAMESPACE b/NAMESPACE index 4e207b15..dc6b08ec 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -25,9 +25,11 @@ export(cfbd_metrics_wp_pregame) export(cfbd_pbp_data) export(cfbd_play_stats_player) export(cfbd_play_stats_types) +export(cfbd_play_types) export(cfbd_player_info) export(cfbd_player_returning) export(cfbd_player_usage) +export(cfbd_plays) export(cfbd_rankings) export(cfbd_ratings_sp) export(cfbd_ratings_sp_conference) diff --git a/NEWS.md b/NEWS.md index b3c63bfe..3944e10c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,24 @@ # cfbfastR +### **v1.2.0** +#### **Add significant documentation to the package** + +* Added mini-vignettes pertaining to CFB Data functionality: + - [```cfbd_betting```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_betting.html), + - [```cfbd_games```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_games.html), + - [```cfbd_plays```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_plays.html), + - [```cfbd_recruiting```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_recruiting.html), + - [```cfbd_stats```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_stats.html), + - [```cfbd_teams```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_teams.html) + +* [Introductory vignette stub](https://saiemgilani.github.io/cfbfastR/articles/intro.html) added + +#### **ESPN/CFBD metrics function variable return standardization** + +* Change `id` variable to `team_id` in [```espn_ratings_fpi()```](https://saiemgilani.github.io/cfbfastR/reference/espn_ratings.html) +* Changed `espn_game_id` variable to `game_id` in [```espn_metrics_wp()```](https://saiemgilani.github.io/cfbfastR/reference/espn_metrics.html), corrected the `away_win_percentage` calculation and added `tie_percentage` to the returns. +* Change `id` variable to `athlete_id` in [```cfbd_metrics_ppa_players_season()```](https://saiemgilani.github.io/cfbfastR/reference/cfbd_metrics.html) + ### **v1.1.0** #### **Add loading from Data Repository functionality** diff --git a/R/helper_database_functions.R b/R/cfb_pbp.R similarity index 71% rename from R/helper_database_functions.R rename to R/cfb_pbp.R index 25dba95a..6af20634 100644 --- a/R/helper_database_functions.R +++ b/R/cfb_pbp.R @@ -1,5 +1,89 @@ -#' Update or Create a cfbfastR Play-by-Play Database -#' `update_cfb_db` updates or creates a database with `cfbfastR` +#' Load cfbfastR play-by-play +#' @name load_cfb_pbp +NULL +#' @title Load cleaned pbp from the data repo +#' @rdname load_cfb_pbp +#' @description helper that loads multiple seasons from the data repo either into memory +#' or writes it into a db using some forwarded arguments in the dots +#' @param seasons A vector of 4-digit years associated with given College Football seasons. +#' @param ... Additional arguments passed to an underlying function that writes +#' the season data into a database (used by \code{\link[=update_cfb_db]{update_cfb_db()}}). +#' @param qs Wheter to use the function [qs::qdeserialize()] for more efficient loading. +#' @export +load_cfb_pbp <- function(seasons, ..., qs = FALSE) { + dots <- rlang::dots_list(...) + + if (all(c("dbConnection", "tablename") %in% names(dots))) in_db <- TRUE else in_db <- FALSE + + if (isTRUE(qs) && !is_installed("qs")) { + usethis::ui_stop("Package {usethis::ui_value('qs')} required for argument {usethis::ui_value('qs = TRUE')}. Please install it.") + } + + most_recent <- most_recent_season() + + if (!all(seasons %in% 2014:most_recent)) { + usethis::ui_stop("Please pass valid seasons between 2014 and {most_recent}") + } + + if (length(seasons) > 1 && is_sequential() && isFALSE(in_db)) { + usethis::ui_info(c( + "It is recommended to use parallel processing when trying to load multiple seasons.", + "Please consider running {usethis::ui_code('future::plan(\"multisession\")')}!", + "Will go on sequentially..." + )) + } + + + p <- progressr::progressor(along = seasons) + + if (isFALSE(in_db)) { + out <- furrr::future_map_dfr(seasons, cfb_single_season, p = p, qs = qs) + } + + if (isTRUE(in_db)) { + purrr::walk(seasons, cfb_single_season, p, ..., qs = qs) + out <- NULL + } + + return(out) +} + +cfb_single_season <- function(season, p, dbConnection = NULL, tablename = NULL, qs = FALSE) { + if (isTRUE(qs)) { + + .url <- glue::glue("https://github.com/saiemgilani/cfbfastR-data/blob/master/data/rds/pbp_players_pos_{season}.qs") + pbp <- qs_from_url(.url) + + } + if (isFALSE(qs)) { + .url <- glue::glue("https://raw.githubusercontent.com/saiemgilani/cfbfastR-data/master/data/rds/pbp_players_pos_{season}.rds") + con <- url(.url) + pbp <- readRDS(con) + close(con) + } + if (!is.null(dbConnection) && !is.null(tablename)) { + DBI::dbWriteTable(dbConnection, tablename, pbp, append = TRUE) + out <- NULL + } else { + out <- pbp + } + p(sprintf("season=%g", season)) + return(out) +} + +# load games file +load_games <- function(){ + .url <- "https://raw.githubusercontent.com/saiemgilani/cfbfastR-data/master/data/games_in_data_repo.csv" + con <- url(.url) + dat <- utils::read.csv(con) + # close(con) + return (dat) +} + +#' @name update_cfb_db +#' @aliases update_cfb_db cfb_db cfb database cfb_pbp_db +#' @title Update or Create a cfbfastR Play-by-Play Database +#' @description `update_cfb_db()` updates or creates a database with `cfbfastR` #' play by play data of all completed games since 2014. #' #' @details This function creates and updates a data table with the name `tblname` @@ -38,10 +122,10 @@ #' [DBI::dbConnect()] (please see details for further information) #' @export update_cfb_db <- function(dbdir = ".", - dbname = "cfb_pbp_db", - tblname = "cfbfastR_pbp", - force_rebuild = FALSE, - db_connection = NULL) { + dbname = "cfb_pbp_db", + tblname = "cfbfastR_pbp", + force_rebuild = FALSE, + db_connection = NULL) { # rule_header("Update cfbfastR Play-by-Play Database") diff --git a/R/cfbd_betting_lines.R b/R/cfbd_betting.R similarity index 84% rename from R/cfbd_betting_lines.R rename to R/cfbd_betting.R index 8bee37c4..e597f781 100644 --- a/R/cfbd_betting_lines.R +++ b/R/cfbd_betting.R @@ -1,13 +1,16 @@ -#' CFBD Betting Endpoint -#' #' @name cfbd_betting -NULL -#' Get Betting information from games -#' -#' @rdname cfbd_betting +#' @aliases betting cfbd_betting cfbd_betting_lines +#' @title CFBD Betting Lines Endpoint +#' @description Get betting lines information from games +#' @examples +#' \donttest{ +#' cfbd_betting_lines(year = 2018, week = 12, team = "Florida State") #' +#' # 7 OTs LSU at TAMU +#' cfbd_betting_lines(year = 2018, week = 13, team = "Texas A&M", conference = "SEC") +#' } #' @param game_id (\emph{Integer} optional): Game ID filter for querying a single game -#' Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function +#' Can be found using the [cfbd_game_info()] function #' @param year (\emph{Integer} required): Year, 4 digit format(\emph{YYYY}) #' @param week (\emph{Integer} optional): Week - values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier) #' @param season_type (\emph{String} default regular): Select Season Type: regular or postseason @@ -16,26 +19,25 @@ NULL #' @param away_team (\emph{String} optional): Away D-I Team #' @param conference (\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr #' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr -#' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC\cr +#' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC #' @param line_provider (\emph{String} optional): Select Line Provider - Caesars, consensus, numberfire, or teamrankings #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' #' @return Betting information for games with the following columns: #' \describe{ -#' \item{\code{game_id}}{integer. Unique game identifier - `game_id`.} -#' \item{\code{season}}{integer. Season parameter.} -#' \item{\code{season_type}}{character. Season Type (regular, postseason, both).} -#' \item{\code{week}}{integer. Week, values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier).} -#' \item{\code{home_team}}{character. Home D-I Team.} -#' \item{\code{home_conference}}{character. Home D-I Conference.} -#' \item{\code{home_score}}{integer. Home Score.} -#' \item{\code{away_team}}{character. Away D-I Team.} -#' \item{\code{away_conference}}{character. Away D-I Conference.} -#' \item{\code{away_score}}{integer. Away Score.} -#' \item{\code{provider}}{character. Line provider.} -#' \item{\code{spread}}{character. Spread for the game.} -#' \item{\code{formatted_spread}}{character. Formatted spread for the game.} -#' \item{\code{over_under}}{character. Over/Under for the game.} +#' \item{`game_id`:integer.}{Unique game identifier - `game_id`.} +#' \item{`season`:integer.}{Season parameter.} +#' \item{`season_type`:character.)}{Season Type (regular, postseason, both} +#' \item{`week`:integer.}{Week, values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier).} +#' \item{`home_team`:character.}{Home D-I Team.} +#' \item{`home_conference`:character.}{Home D-I Conference.} +#' \item{`home_score`:integer.}{Home Score.} +#' \item{`away_team`:character.}{Away D-I Team.} +#' \item{`away_conference`:character.}{Away D-I Conference.} +#' \item{`away_score`:integer.}{Away Score.} +#' \item{`provider`:character.}{Line provider.} +#' \item{`spread`:character.}{Spread for the game.} +#' \item{`formatted_spread`:character.}{Formatted spread for the game.} +#' \item{`over_under`:character.}{Over/Under for the game.} #' } #' @source \url{https://api.collegefootballdata.com/lines} #' @keywords Betting Lines @@ -49,13 +51,6 @@ NULL #' @importFrom dplyr filter as_tibble rename #' @importFrom tidyr unnest #' @export -#' @examples -#' \donttest{ -#' cfbd_betting_lines(year = 2018, week = 12, team = "Florida State") -#' -#' # 7 OTs LSU at TAMU -#' cfbd_betting_lines(year = 2018, week = 13, team = "Texas A&M", conference = "SEC") -#' } #' cfbd_betting_lines <- function(game_id = NULL, year = NULL, diff --git a/R/cfbd_coaches.R b/R/cfbd_coaches.R index 7a9a3fae..65bf2f12 100644 --- a/R/cfbd_coaches.R +++ b/R/cfbd_coaches.R @@ -1,7 +1,12 @@ -#' Coach Information Search -#' +#' +#' @name cfbd_coaches +#' @aliases coaches cfbd_coaches +#' @title CFBD Coaches Endpoint +#' @description Coach Information Search #' A coach search function which provides coaching records and school history for a given coach -#' +#' ```r +#' cfbd_coaches(first = "Nick", last = "Saban", team = "alabama") +#' ```` #' @param first (\emph{String} optional): First name for the coach you are trying to look up #' @param last (\emph{String} optional): Last name for the coach you are trying to look up #' @param team (\emph{String} optional): Team - Select a valid team, D1 football @@ -9,25 +14,25 @@ #' @param min_year (\emph{Integer} optional): Minimum Year filter (inclusive), 4 digit format (\emph{YYYY}). #' @param max_year (\emph{Integer} optional): Maximum Year filter (inclusive), 4 digit format (\emph{YYYY}) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' @return \code{\link[cfbfastR:cfbd_coaches]{cfbfastR::cfbd_coaches()}} - A data frame with coach information with the following columns: +#' @return [cfbd_coaches()] - A data frame with coach information with the following columns: #' \describe{ -#' \item{\code{first_name}}{character. First name of coach.} -#' \item{\code{last_name}}{character. Last name of coach.} -#' \item{\code{school}}{character. School of coach.} -#' \item{\code{year}}{integer. Season of record.} -#' \item{\code{games}}{integer. Games as coach.} -#' \item{\code{wins}}{integer. Wins for the season.} -#' \item{\code{losses}}{integer. Losses for the season.} -#' \item{\code{ties}}{integer. Ties for the season.} -#' \item{\code{preseason_rank}}{integer. Preseason rank for the school of coach.} -#' \item{\code{postseason_rank}}{integer. Postseason rank for the school of coach.} -#' \item{\code{srs}}{character. Simple Rating System adjustment for team.} -#' \item{\code{sp_overall}}{character. Bill Connelly's SP+ overall for team.} -#' \item{\code{sp_offense}}{character. Bill Connelly's SP+ offense for team.} -#' \item{\code{sp_defense}}{character. Bill Connelly's SP+ defense for team.} +#' \item{`first_name`:character.}{First name of coach.} +#' \item{`last_name`:character.}{Last name of coach.} +#' \item{`school`:character.}{School of coach.} +#' \item{`year`:integer.}{Season of record.} +#' \item{`games`:integer.}{Games as coach.} +#' \item{`wins`:integer.}{Wins for the season.} +#' \item{`losses`:integer.}{ Losses for the season.} +#' \item{`ties`:integer.}{Ties for the season.} +#' \item{`preseason_rank`:integer.}{Preseason rank for the school of coach.} +#' \item{`postseason_rank`:integer.}{Postseason rank for the school of coach.} +#' \item{`srs`:character.}{Simple Rating System adjustment for team.} +#' \item{`sp_overall`:character.}{Bill Connelly's SP+ overall for team.} +#' \item{`sp_offense`:character.}{Bill Connelly's SP+ offense for team.} +#' \item{`sp_defense`:character.}{Bill Connelly's SP+ defense for team.} #' } #' @source \url{https://api.collegefootballdata.com/coaches} -#' @keywords Recruiting +#' @keywords Coaches #' @importFrom jsonlite fromJSON #' @importFrom httr GET #' @importFrom utils URLencode diff --git a/R/cfbd_conferences.R b/R/cfbd_conferences.R index 412307ad..f04496a2 100644 --- a/R/cfbd_conferences.R +++ b/R/cfbd_conferences.R @@ -1,12 +1,23 @@ -#' CFB Conference Information -#' -#' Pulls all college football conferences and returns as data frame the following fields: -#' @return \code{\link[cfbfastR:cfbd_conferences]{cfbfastR::cfbd_conferences()}} - A data frame with 11 rows and 4 variables: +#' @name cfbd_conferences +#' @aliases conferences cfbd_conferences +#' @title CFBD Conferences Endpoint +#' @description CFB Conference Information +#' Pulls all college football conferences and returns as data frame +#' +#' You can call this function simply with +#' ```r +#' cfbd_conferences() +#' ``` +#' @examples +#' \donttest{ +#' cfbd_conferences() +#' } +#' @return [cfbd_conferences()] - A data frame with 11 rows and 4 variables: #' \describe{ -#' \item{conference_id}{Referencing conference id} -#' \item{name}{Conference name} -#' \item{long_name}{Long name for Conference} -#' \item{abbreviation}{Conference abbreviation} +#' \item{`conference_id`:}{Referencing conference id.} +#' \item{`name`:}{Conference name.} +#' \item{`long_name`:}{Long name for Conference.} +#' \item{`abbreviation`:}{Conference abbreviation.} #' ... #' } #' @source \url{https://api.collegefootballdata.com/conferences} @@ -16,10 +27,6 @@ #' @import dplyr #' @import tidyr #' @export -#' @examples -#' \donttest{ -#' cfbd_conferences() -#' } cfbd_conferences <- function() { full_url <- "https://api.collegefootballdata.com/conferences" diff --git a/R/cfbd_drives.R b/R/cfbd_drives.R index ff860d77..1315dcb1 100644 --- a/R/cfbd_drives.R +++ b/R/cfbd_drives.R @@ -1,5 +1,18 @@ -#' Get results information from games +#' @name cfbd_drives +#' @aliases drives cfbd_drives +#' @title CFBD Drives Endpoint +#' @description Get CFB game drives +#' ```r +#' cfbd_drives(2018, week = 1, team = "TCU") #' +#' cfbd_drives(2018, team = "Texas A&M", defense_conference = "SEC") +#' ```` +#' @examples +#' \donttest{ +#' cfbd_drives(2018, week = 1, team = "TCU") +#' +#' cfbd_drives(2018, team = "Texas A&M", defense_conference = "SEC") +#' } #' @param year (\emph{Integer} required): Year, 4 digit format (\emph{YYYY}) #' @param season_type (\emph{String} default regular): Select Season Type: regular, postseason, or both #' @param week (\emph{Integer} optional): Week - values from 1-15, 1-14 for seasons pre-playoff, i.e. 2013 or earlier @@ -16,35 +29,41 @@ #' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr #' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' -#' @return \code{\link[cfbfastR:cfbd_drives]{cfbfastR::cfbd_drives()}} - A data frame with 23 variables as follows: +#' @return [cfbd_drives()] - A data frame with 23 variables as follows: #' \describe{ -#' \item{\code{offense}}{character. Drive offense.} -#' \item{\code{offense_conference}}{character. Drive offense's conference.} -#' \item{\code{defense}}{character. Drive defense.} -#' \item{\code{defense_conference}}{character. Drive defense's conference.} -#' \item{\code{game_id}}{integer. Unique game identifier - `game_id`.} -#' \item{\code{drive_id}}{character. Unique drive identifier - `drive_id`.} -#' \item{\code{drive_number}}{integer. Drive number in game.} -#' \item{\code{scoring}}{logical. Drive ends in a score.} -#' \item{\code{start_period}}{integer. Period (or Quarter) in which the drive starts.} -#' \item{\code{start_yardline}}{integer. Yard line at the drive start.} -#' \item{\code{start_yards_to_goal}}{integer. Yards-to-Goal at the drive start.} -#' \item{\code{end_period}}{integer. Period (or Quarter) in which the drive ends.} -#' \item{\code{end_yardline}}{integer. Yard line at drive end.} -#' \item{\code{end_yards_to_goal}}{integer. Yards-to-Goal at drive end.} -#' \item{\code{plays}}{integer. Number of drive plays.} -#' \item{\code{yards}}{integer. Total drive yards.} -#' \item{\code{drive_result}}{character. Result of the drive description.} -#' \item{\code{time_minutes_start}}{integer. Minutes at drive start.} -#' \item{\code{time_seconds_start}}{integer. Seconds at drive start.} -#' \item{\code{time_minutes_end}}{integer. Minutes at drive end.} -#' \item{\code{time_seconds_end}}{integer. Seconds at drive end.} -#' \item{\code{time_minutes_elapsed}}{double. Minutes elapsed during drive.} -#' \item{\code{time_seconds_elapsed}}{integer. Seconds elapsed during drive.} +#' \item{`offense`:character.}{Drive offense.} +#' \item{`offense_conference`:character.}{Drive offense's conference.} +#' \item{`defense`:character.}{Drive defense.} +#' \item{`defense_conference`:character.}{Drive defense's conference.} +#' \item{`game_id`:integer.}{Unique game identifier - `game_id`.} +#' \item{`drive_id`:character.}{Unique drive identifier - `drive_id`.} +#' \item{`drive_number`:integer.}{Drive number in game.} +#' \item{`scoring`:logical.}{Drive ends in a score.} +#' \item{`start_period`:integer.}{Period (or Quarter) in which the drive starts.} +#' \item{`start_yardline`:integer.}{Yard line at the drive start.} +#' \item{`start_yards_to_goal`:integer.}{Yards-to-Goal at the drive start.} +#' \item{`end_period`:integer.}{Period (or Quarter) in which the drive ends.} +#' \item{`end_yardline`:integer.}{Yard line at drive end.} +#' \item{`end_yards_to_goal`:integer.}{Yards-to-Goal at drive end.} +#' \item{`plays`:integer.}{Number of drive plays.} +#' \item{`yards`:integer.}{Total drive yards.} +#' \item{`drive_result`:character.}{Result of the drive description.} +#' \item{`is_home_offense`:logical.}{Flag for if the offense on the field is the home offense} +#' \item{`start_offense_score`:numeric.}{Offense score at the start of the drive.} +#' \item{`start_defense_score`:numeric.}{Defense score at the start of the drive.} +#' \item{`end_offense_score`:numeric.}{Offense score at the end of the drive.} +#' \item{`end_defense_score`:numeric.}{Defense score at the end of the drive.} +#' \item{`time_minutes_start`:integer.}{Minutes at drive start.} +#' \item{`time_seconds_start`:integer.}{Seconds at drive start.} +#' \item{`time_minutes_end`:integer.}{Minutes at drive end.} +#' \item{`time_seconds_end`:integer.}{Seconds at drive end.} +#' \item{`time_minutes_elapsed`:double.}{Minutes elapsed during drive.} +#' \item{`time_seconds_elapsed`:integer.}{Seconds elapsed during drive.} #' } #' @source \url{https://api.collegefootballdata.com/drives} #' @keywords Drives +NULL + #' @importFrom jsonlite fromJSON #' @importFrom httr GET #' @importFrom utils URLencode @@ -53,13 +72,6 @@ #' @import dplyr #' @import tidyr #' @export -#' @examples -#' \donttest{ -#' cfbd_drives(2018, week = 1, team = "TCU") -#' -#' cfbd_drives(2018, team = "Texas A&M", defense_conference = "SEC") -#' } -#' cfbd_drives <- function(year, season_type = "regular", week = NULL, diff --git a/R/cfbd_games.R b/R/cfbd_games.R index 3990cb91..f7d09820 100644 --- a/R/cfbd_games.R +++ b/R/cfbd_games.R @@ -1,9 +1,43 @@ -#' CFBD Games Endpoint -#' #' @name cfbd_games -NULL -#' Get results information from games -#' @rdname cfbd_games +#' @aliases cfbd_games cfbd_game_info cfbd_calendar cfbd_game_media cfbd_game_box_advanced cfbd_game_player_stats cfbd_game_records cfbd_game_team_stats +#' @title CFBD Games Endpoint +#' @description Get results, statistics and information for games +#' \describe{ +#' \item{`cfbd_game_info()`: Get results information from games}{.} +#' \item{`cfbd_calendar()`: Calendar - Returns calendar of weeks by season}{.} +#' \item{`cfbd_game_media()`: Get Game media information (TV, radio, etc)}{.} +#' \item{`cfbd_game_box_advanced()`: Get game advanced box score information}{.} +#' \item{`cfbd_game_player_stats()`: Get results information from games}{.} +#' \item{`cfbd_game_records()`: Get Team records by year}{.} +#' \item{`cfbd_game_team_stats()`: Get Team Statistics by Game}{.} +#' } +#' @examples +#' \donttest{ +#' cfbd_game_info(2018, week = 1) +#' +#' cfbd_game_info(2018, week = 7, conference = "Ind") +#' +#' # 7 OTs LSU @ TAMU +#' cfbd_game_info(2018, week = 13, team = "Texas A&M", quarter_scores = TRUE) +#' +#' cfbd_calendar(2019) +#' +#' cfbd_game_media(2019, week = 4, conference = "ACC") +#' +#' cfbd_game_box_advanced(game_id = 401114233) +#' +#' cfbd_game_player_stats(2018, week = 15, conference = "Ind") +#' +#' cfbd_game_player_stats(2013, week = 1, team = "Florida State", category = "passing") +#' +#' cfbd_game_records(2018, team = "Notre Dame") +#' +#' cfbd_game_records(2013, team = "Florida State") +#' +#' cfbd_game_team_stats(2019, team = "LSU") +#' +#' cfbd_game_team_stats(2013, team = "Florida State") +#' } #' @param year (\emph{Integer} required): Year, 4 digit format(\emph{YYYY}) #' @param week (\emph{Integer} optional): Week - values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier) #' @param season_type (\emph{String} default regular): Select Season Type: regular, postseason, or both @@ -17,32 +51,32 @@ NULL #' @param quarter_scores (\emph{Logical} default FALSE): This is a parameter to return the #' list columns that give the score at each quarter: `home_line_scores` and `away_line_scores`.\cr #' I have defaulted the parameter to false so that you will not have to go to the trouble of dropping it. -#' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function +#' @param verbose (\emph{Logical}, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} - A data frame with 22 variables: +#' @return [cfbd_game_info()] - A data frame with 22 variables: #' \describe{ -#' \item{\code{game_id}}{integer.} -#' \item{\code{season}}{integer.} -#' \item{\code{week}}{integer.} -#' \item{\code{season_type}}{character.} -#' \item{\code{start_date}}{character.} -#' \item{\code{start_time_tbd}}{logical.} -#' \item{\code{neutral_site}}{logical.} -#' \item{\code{conference_game}}{logical.} -#' \item{\code{attendance}}{integer.} -#' \item{\code{venue_id}}{integer.} -#' \item{\code{venue}}{character.} -#' \item{\code{home_id}}{integer.} -#' \item{\code{home_team}}{character.} -#' \item{\code{home_conference}}{character.} -#' \item{\code{home_points}}{integer.} -#' \item{\code{home_post_win_prob}}{character.} -#' \item{\code{away_id}}{integer.} -#' \item{\code{away_team}}{character.} -#' \item{\code{away_conference}}{character.} -#' \item{\code{away_points}}{integer.} -#' \item{\code{away_post_win_prob}}{character.} -#' \item{\code{excitement_index}}{character.} +#' \item{`game_id`: integer.}{Referencing game id.} +#' \item{`season`: integer.}{Season of the game.} +#' \item{`week`: integer.}{Game week.} +#' \item{`season_type`: character.}{Season type of the game.} +#' \item{`start_date`: character.}{Game date.} +#' \item{`start_time_tbd`: logical.}{TRUE/FALSE flag for if the game's start time is to be determined.} +#' \item{`neutral_site`: logical.}{TRUE/FALSE flag for the game taking place at a neutral site.} +#' \item{`conference_game`: logical.}{TRUE/FALSE flag for this game qualifying as a conference game.} +#' \item{`attendance`: integer.}{Reported attendance at the game.} +#' \item{`venue_id`: integer.}{Referencing venue id.} +#' \item{`venue`: character.}{Venue name.} +#' \item{`home_id`: integer.}{Home team referencing id.} +#' \item{`home_team`: character.}{Home team name.} +#' \item{`home_conference`: character.}{Home team conference.} +#' \item{`home_points`: integer.}{Home team points.} +#' \item{`home_post_win_prob`: character.}{Home team post-game win probability.} +#' \item{`away_id`: integer.}{Away team referencing id.} +#' \item{`away_team`: character.}{Away team name.} +#' \item{`away_conference`: character.}{Away team conference.} +#' \item{`away_points`: integer.}{Away team points.} +#' \item{`away_post_win_prob`: character.}{Away team post-game win probability.} +#' \item{`excitement_index`: character.}{Game excitement index.} #' } #' @source \url{https://api.collegefootballdata.com/games} #' @keywords Game Info @@ -54,15 +88,6 @@ NULL #' @import dplyr #' @import tidyr #' @export -#' @examples -#' \donttest{ -#' cfbd_game_info(2018, week = 1) -#' -#' cfbd_game_info(2018, week = 7, conference = "Ind") -#' -#' # 7 OTs LSU @ TAMU -#' cfbd_game_info(2018, week = 13, team = "Texas A&M", quarter_scores = TRUE) -#' } cfbd_game_info <- function(year, week = NULL, season_type = "regular", @@ -190,11 +215,17 @@ cfbd_game_info <- function(year, return(df) } -#' Calendar - Returns calendar of weeks by season #' @rdname cfbd_games #' @param year (\emph{Integer} required): Year, 4 digit format (\emph{YYYY}) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' @return \code{\link[cfbfastR:cfbd_calendar]{cfbfastR::cfbd_calendar()}} A data frame with 5 variables: +#' @return [cfbd_calendar()] - A data frame with 5 variables: +#' \describe{ +#' \item{`season`: character.}{Calendar season.} +#' \item{`week`: integer.}{Calendar game week.} +#' \item{`season_type`: character}{Season type of calendar week.} +#' \item{`first_game_start`: character.}{First game start time of the calendar week.} +#' \item{`last_game_start`: character.}{Last game start time of the calendar week.} +#' } #' @source \url{https://api.collegefootballdata.com/calendar} #' @importFrom dplyr rename mutate #' @importFrom janitor clean_names @@ -204,11 +235,6 @@ cfbd_game_info <- function(year, #' @importFrom assertthat assert_that #' @importFrom glue glue #' @export -#' @examples -#' \donttest{ -#' cfbd_calendar(2019) -#' } -#' cfbd_calendar <- function(year, verbose = FALSE) { @@ -261,7 +287,6 @@ cfbd_calendar <- function(year, return(df) } -#' Get Game media information (TV, radio, etc) #' @rdname cfbd_games #' @param year (\emph{Integer} required): Year, 4 digit format (\emph{YYYY}) #' @param week (\emph{Integer} optional): Week, values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier) @@ -273,21 +298,21 @@ cfbd_calendar <- function(year, #' @param media_type (\emph{String} optional): Media type filter: tv, radio, web, ppv, or mobile #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_game_media]{cfbfastR::cfbd_game_media()}} - A data frame with 13 variables: +#' @return [cfbd_game_media()] - A data frame with 13 variables: #' \describe{ -#' \item{\code{game_id}}{integer.} -#' \item{\code{season}}{integer.} -#' \item{\code{week}}{integer.} -#' \item{\code{season_type}}{character.} -#' \item{\code{start_time}}{character.} -#' \item{\code{is_start_time_tbd}}{logical.} -#' \item{\code{home_team}}{character.} -#' \item{\code{home_conference}}{character.} -#' \item{\code{away_team}}{character.} -#' \item{\code{away_conference}}{character.} -#' \item{\code{tv}}{list.} -#' \item{\code{radio}}{logical.} -#' \item{\code{web}}{list.} +#' \item{`game_id`: integer.}{Referencing game id.} +#' \item{`season`: integer.}{Season of the game.} +#' \item{`week`: integer.}{Game week.} +#' \item{`season_type`: character.}{Season type of the game.} +#' \item{`start_time`: character.}{Game start time.} +#' \item{`is_start_time_tbd`: logical.}{TRUE/FALSE flag for if the start time is still to be determined.} +#' \item{`home_team`: character.}{Home team of the game.} +#' \item{`home_conference`: character.}{Conference of the home team.} +#' \item{`away_team`: character.}{Away team of the game.} +#' \item{`away_conference`: character.}{Conference of the away team.} +#' \item{`tv`: list.}{TV broadcast networks.} +#' \item{`radio`: logical.}{Radio broadcast networks.} +#' \item{`web`: list.}{Web viewing platforms carrying the game.} #' } #' @source \url{https://api.collegefootballdata.com/games/media} #' @keywords Game Info @@ -297,14 +322,9 @@ cfbd_calendar <- function(year, #' @importFrom assertthat assert_that #' @importFrom janitor clean_names #' @importFrom glue glue -#' @import dplyr -#' @import tidyr +#' @importFrom dplyr rename select +#' @importFrom tidyr everything pivot_wider #' @export -#' @examples -#' -#' \donttest{ -#' cfbd_game_media(2019, week = 4, conference = "ACC") -#' } cfbd_game_media <- function(year, week = NULL, season_type = "both", @@ -409,83 +429,82 @@ cfbd_game_media <- function(year, } -#' Get game advanced box score information #' @rdname cfbd_games #' @param game_id (\emph{Integer} required): Game ID filter for querying a single game -#' Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function +#' Can be found using the [cfbd_game_info()] function #' @param long (\emph{Logical} default `FALSE`): Return the data in a long format. #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' @return \code{\link[cfbfastR:cfbd_game_box_advanced]{cfbfastR::cfbd_game_box_advanced()}} - A data frame with 2 rows and 69 variables: +#' @return [cfbd_game_box_advanced()] - A data frame with 2 rows and 69 variables: #' \describe{ -#' \item{\code{team}}{character.} -#' \item{\code{plays}}{double.} -#' \item{\code{ppa_overall_total}}{double.} -#' \item{\code{ppa_overall_quarter1}}{double.} -#' \item{\code{ppa_overall_quarter2}}{double.} -#' \item{\code{ppa_overall_quarter3}}{double.} -#' \item{\code{ppa_overall_quarter4}}{double.} -#' \item{\code{ppa_passing_total}}{double.} -#' \item{\code{ppa_passing_quarter1}}{double.} -#' \item{\code{ppa_passing_quarter2}}{double.} -#' \item{\code{ppa_passing_quarter3}}{double.} -#' \item{\code{ppa_passing_quarter4}}{double.} -#' \item{\code{ppa_rushing_total}}{double.} -#' \item{\code{ppa_rushing_quarter1}}{double.} -#' \item{\code{ppa_rushing_quarter2}}{double.} -#' \item{\code{ppa_rushing_quarter3}}{double.} -#' \item{\code{ppa_rushing_quarter4}}{double.} -#' \item{\code{cumulative_ppa_plays}}{double.} -#' \item{\code{cumulative_ppa_overall_total}}{double.} -#' \item{\code{cumulative_ppa_overall_quarter1}}{double.} -#' \item{\code{cumulative_ppa_overall_quarter2}}{double.} -#' \item{\code{cumulative_ppa_overall_quarter3}}{double.} -#' \item{\code{cumulative_ppa_overall_quarter4}}{double.} -#' \item{\code{cumulative_ppa_passing_total}}{double.} -#' \item{\code{cumulative_ppa_passing_quarter1}}{double.} -#' \item{\code{cumulative_ppa_passing_quarter2}}{double.} -#' \item{\code{cumulative_ppa_passing_quarter3}}{double.} -#' \item{\code{cumulative_ppa_passing_quarter4}}{double.} -#' \item{\code{cumulative_ppa_rushing_total}}{double.} -#' \item{\code{cumulative_ppa_rushing_quarter1}}{double.} -#' \item{\code{cumulative_ppa_rushing_quarter2}}{double.} -#' \item{\code{cumulative_ppa_rushing_quarter3}}{double.} -#' \item{\code{cumulative_ppa_rushing_quarter4}}{double.} -#' \item{\code{success_rates_overall_total}}{double.} -#' \item{\code{success_rates_overall_quarter1}}{double.} -#' \item{\code{success_rates_overall_quarter2}}{double.} -#' \item{\code{success_rates_overall_quarter3}}{double.} -#' \item{\code{success_rates_overall_quarter4}}{double.} -#' \item{\code{success_rates_standard_downs_total}}{double.} -#' \item{\code{success_rates_standard_downs_quarter1}}{double.} -#' \item{\code{success_rates_standard_downs_quarter2}}{double.} -#' \item{\code{success_rates_standard_downs_quarter3}}{double.} -#' \item{\code{success_rates_standard_downs_quarter4}}{double.} -#' \item{\code{success_rates_passing_downs_total}}{double.} -#' \item{\code{success_rates_passing_downs_quarter1}}{double.} -#' \item{\code{success_rates_passing_downs_quarter2}}{double.} -#' \item{\code{success_rates_passing_downs_quarter3}}{double.} -#' \item{\code{success_rates_passing_downs_quarter4}}{double.} -#' \item{\code{explosiveness_overall_total}}{double.} -#' \item{\code{explosiveness_overall_quarter1}}{double.} -#' \item{\code{explosiveness_overall_quarter2}}{double.} -#' \item{\code{explosiveness_overall_quarter3}}{double.} -#' \item{\code{explosiveness_overall_quarter4}}{double.} -#' \item{\code{rushing_power_success}}{double.} -#' \item{\code{rushing_stuff_rate}}{double.} -#' \item{\code{rushing_line_yds}}{double.} -#' \item{\code{rushing_line_yd_avg}}{double.} -#' \item{\code{rushing_second_lvl_yds}}{double.} -#' \item{\code{rushing_second_lvl_yd_avg}}{double.} -#' \item{\code{rushing_open_field_yds}}{double.} -#' \item{\code{rushing_open_field_yd_avg}}{double.} -#' \item{\code{havoc_total}}{double.} -#' \item{\code{havoc_front_seven}}{double.} -#' \item{\code{havoc_db}}{double.} -#' \item{\code{scoring_opps_opportunities}}{double.} -#' \item{\code{scoring_opps_points}}{double.} -#' \item{\code{scoring_opps_pts_per_opp}}{double.} -#' \item{\code{field_pos_avg_start}}{double.} -#' \item{\code{field_pos_avg_starting_predicted_pts}}{double.} +#' \item{`team`: character.}{.} +#' \item{`plays`: double.}{.} +#' \item{`ppa_overall_total`: double.}{.} +#' \item{`ppa_overall_quarter1`: double.}{.} +#' \item{`ppa_overall_quarter2`: double.}{.} +#' \item{`ppa_overall_quarter3`: double.}{.} +#' \item{`ppa_overall_quarter4`: double.}{.} +#' \item{`ppa_passing_total`: double.}{.} +#' \item{`ppa_passing_quarter1`: double.}{.} +#' \item{`ppa_passing_quarter2`: double.}{.} +#' \item{`ppa_passing_quarter3`: double.}{.} +#' \item{`ppa_passing_quarter4`: double.}{.} +#' \item{`ppa_rushing_total`: double.}{.} +#' \item{`ppa_rushing_quarter1`: double.}{.} +#' \item{`ppa_rushing_quarter2`: double.}{.} +#' \item{`ppa_rushing_quarter3`: double.}{.} +#' \item{`ppa_rushing_quarter4`: double.}{.} +#' \item{`cumulative_ppa_plays`: double.}{.} +#' \item{`cumulative_ppa_overall_total`: double.}{.} +#' \item{`cumulative_ppa_overall_quarter1`: double.}{.} +#' \item{`cumulative_ppa_overall_quarter2`: double.}{.} +#' \item{`cumulative_ppa_overall_quarter3`: double.}{.} +#' \item{`cumulative_ppa_overall_quarter4`: double.}{.} +#' \item{`cumulative_ppa_passing_total`: double.}{.} +#' \item{`cumulative_ppa_passing_quarter1`: double.}{.} +#' \item{`cumulative_ppa_passing_quarter2`: double.}{.} +#' \item{`cumulative_ppa_passing_quarter3`: double.}{.} +#' \item{`cumulative_ppa_passing_quarter4`: double.}{.} +#' \item{`cumulative_ppa_rushing_total`: double.}{.} +#' \item{`cumulative_ppa_rushing_quarter1`: double.}{.} +#' \item{`cumulative_ppa_rushing_quarter2`: double.}{.} +#' \item{`cumulative_ppa_rushing_quarter3`: double.}{.} +#' \item{`cumulative_ppa_rushing_quarter4`: double.}{.} +#' \item{`success_rates_overall_total`: double.}{.} +#' \item{`success_rates_overall_quarter1`: double.}{.} +#' \item{`success_rates_overall_quarter2`: double.}{.} +#' \item{`success_rates_overall_quarter3`: double.}{.} +#' \item{`success_rates_overall_quarter4`: double.}{.} +#' \item{`success_rates_standard_downs_total`: double.}{.} +#' \item{`success_rates_standard_downs_quarter1`: double.}{.} +#' \item{`success_rates_standard_downs_quarter2`: double.}{.} +#' \item{`success_rates_standard_downs_quarter3`: double.}{.} +#' \item{`success_rates_standard_downs_quarter4`: double.}{.} +#' \item{`success_rates_passing_downs_total`: double.}{.} +#' \item{`success_rates_passing_downs_quarter1`: double.}{.} +#' \item{`success_rates_passing_downs_quarter2`: double.}{.} +#' \item{`success_rates_passing_downs_quarter3`: double.}{.} +#' \item{`success_rates_passing_downs_quarter4`: double.}{.} +#' \item{`explosiveness_overall_total`: double.}{.} +#' \item{`explosiveness_overall_quarter1`: double.}{.} +#' \item{`explosiveness_overall_quarter2`: double.}{.} +#' \item{`explosiveness_overall_quarter3`: double.}{.} +#' \item{`explosiveness_overall_quarter4`: double.}{.} +#' \item{`rushing_power_success`: double.}{.} +#' \item{`rushing_stuff_rate`: double.}{.} +#' \item{`rushing_line_yds`: double.}{.} +#' \item{`rushing_line_yd_avg`: double.}{.} +#' \item{`rushing_second_lvl_yds`: double.}{.} +#' \item{`rushing_second_lvl_yd_avg`: double.}{.} +#' \item{`rushing_open_field_yds`: double.}{.} +#' \item{`rushing_open_field_yd_avg`: double.}{.} +#' \item{`havoc_total`: double.}{.} +#' \item{`havoc_front_seven`: double.}{.} +#' \item{`havoc_db`: double.}{.} +#' \item{`scoring_opps_opportunities`: double.}{.} +#' \item{`scoring_opps_points`: double.}{.} +#' \item{`scoring_opps_pts_per_opp`: double.}{.} +#' \item{`field_pos_avg_start`: double.}{.} +#' \item{`field_pos_avg_starting_predicted_pts`: double.}{.} #' } #' @source \url{https://api.collegefootballdata.com/game/box/advanced} #' @keywords Game Advanced Box Score @@ -500,10 +519,7 @@ cfbd_game_media <- function(year, #' @import tidyr #' @import purrr #' @export -#' @examples -#' \donttest{ -#' cfbd_game_box_advanced(game_id = 401114233) -#' } + cfbd_game_box_advanced <- function(game_id, long = FALSE, verbose = FALSE) { if (!is.null(game_id)) { @@ -613,8 +629,6 @@ cfbd_game_box_advanced <- function(game_id, long = FALSE, return(df) } -#' Get results information from games -#' #' @rdname cfbd_games #' @param year (\emph{Integer} required): Year, 4 digit format(\emph{YYYY}) #' @param week (\emph{Integer} optional): Week - values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier) @@ -628,43 +642,43 @@ cfbd_game_box_advanced <- function(game_id, long = FALSE, #' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr #' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC\cr #' @param game_id (\emph{Integer} optional): Game ID filter for querying a single game -#' Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function +#' Can be found using the [cfbd_game_info()] function #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_game_player_stats]{cfbfastR::cfbd_game_player_stats()}} - A data frame with 32 variables: +#' @return [cfbd_game_player_stats()] - A data frame with 32 variables: #' \describe{ -#' \item{\code{game_id}}{integer.} -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{home_away}}{character.} -#' \item{\code{points}}{integer.} -#' \item{\code{category}}{character.} -#' \item{\code{athlete_id}}{character.} -#' \item{\code{name}}{character.} -#' \item{\code{c_att}}{character.} -#' \item{\code{yds}}{double.} -#' \item{\code{avg}}{double.} -#' \item{\code{td}}{double.} -#' \item{\code{int}}{double.} -#' \item{\code{qbr}}{double.} -#' \item{\code{car}}{double.} -#' \item{\code{long}}{double.} -#' \item{\code{rec}}{double.} -#' \item{\code{no}}{double.} -#' \item{\code{fg}}{character.} -#' \item{\code{pct}}{double.} -#' \item{\code{xp}}{character.} -#' \item{\code{pts}}{double.} -#' \item{\code{tb}}{double.} -#' \item{\code{in_20}}{double.} -#' \item{\code{fum}}{double.} -#' \item{\code{lost}}{double.} -#' \item{\code{tot}}{double.} -#' \item{\code{solo}}{double.} -#' \item{\code{sacks}}{double.} -#' \item{\code{tfl}}{double.} -#' \item{\code{pd}}{double.} -#' \item{\code{qb_hur}}{double.} +#' \item{`game_id`: integer.}{.} +#' \item{`team`: character.}{.} +#' \item{`conference`: character.}{.} +#' \item{`home_away`: character.}{.} +#' \item{`points`: integer.}{.} +#' \item{`category`: character.}{.} +#' \item{`athlete_id`: character.}{.} +#' \item{`name`: character.}{.} +#' \item{`c_att`: character.}{.} +#' \item{`yds`: double.}{.} +#' \item{`avg`: double.}{.} +#' \item{`td`: double.}{.} +#' \item{`int`: double.}{.} +#' \item{`qbr`: double.}{.} +#' \item{`car`: double.}{.} +#' \item{`long`: double.}{.} +#' \item{`rec`: double.}{.} +#' \item{`no`: double.}{.} +#' \item{`fg`: character.}{.} +#' \item{`pct`: double.}{.} +#' \item{`xp`: character.}{.} +#' \item{`pts`: double.}{.} +#' \item{`tb`: double.}{.} +#' \item{`in_20`: double.}{.} +#' \item{`fum`: double.}{.} +#' \item{`lost`: double.}{.} +#' \item{`tot`: double.}{.} +#' \item{`solo`: double.}{.} +#' \item{`sacks`: double.}{.} +#' \item{`tfl`: double.}{.} +#' \item{`pd`: double.}{.} +#' \item{`qb_hur`: double.}{.} #' } #' @source \url{https://api.collegefootballdata.com/games/players} #' @keywords Game Info @@ -678,13 +692,7 @@ cfbd_game_box_advanced <- function(game_id, long = FALSE, #' @import tidyr #' @import purrr #' @export -#' @examples -#' \donttest{ -#' cfbd_game_player_stats(2018, week = 15, conference = "Ind") -#' -#' cfbd_game_player_stats(2013, week = 1, team = "Florida State", category = "passing") -#' } -#' + cfbd_game_player_stats <- function(year, week = NULL, season_type = "regular", @@ -844,8 +852,8 @@ cfbd_game_player_stats <- function(year, } -#' Get Team records by year -#' + + #' @rdname cfbd_games #' @param year (\emph{Integer} optional): Year, 4 digit format (\emph{YYYY}) #' @param team (\emph{String} optional): Team - Select a valid team, D1 football @@ -853,28 +861,28 @@ cfbd_game_player_stats <- function(year, #' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr #' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' @return \code{\link[cfbfastR:cfbd_game_records]{cfbfastR::cfbd_game_records()}} - A data frame with 20 variables: +#' @return [cfbd_game_records()] - A data frame with 20 variables: #' \describe{ -#' \item{\code{year}}{integer.} -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{division}}{character.} -#' \item{\code{total_games}}{integer.} -#' \item{\code{total_wins}}{integer.} -#' \item{\code{total_losses}}{integer.} -#' \item{\code{total_ties}}{integer.} -#' \item{\code{conference_games}}{integer.} -#' \item{\code{conference_wins}}{integer.} -#' \item{\code{conference_losses}}{integer.} -#' \item{\code{conference_ties}}{integer.} -#' \item{\code{home_games}}{integer.} -#' \item{\code{home_wins}}{integer.} -#' \item{\code{home_losses}}{integer.} -#' \item{\code{home_ties}}{integer.} -#' \item{\code{away_games}}{integer.} -#' \item{\code{away_wins}}{integer.} -#' \item{\code{away_losses}}{integer.} -#' \item{\code{away_ties}}{integer.} +#' \item{`year`: integer.}{.} +#' \item{`team`: character.}{.} +#' \item{`conference`: character.}{.} +#' \item{`division`: character.}{.} +#' \item{`total_games`: integer.}{.} +#' \item{`total_wins`: integer.}{.} +#' \item{`total_losses`: integer.}{.} +#' \item{`total_ties`: integer.}{.} +#' \item{`conference_games`: integer.}{.} +#' \item{`conference_wins`: integer.}{.} +#' \item{`conference_losses`: integer.}{.} +#' \item{`conference_ties`: integer.}{.} +#' \item{`home_games`: integer.}{.} +#' \item{`home_wins`: integer.}{.} +#' \item{`home_losses`: integer.}{.} +#' \item{`home_ties`: integer.}{.} +#' \item{`away_games`: integer.}{.} +#' \item{`away_wins`: integer.}{.} +#' \item{`away_losses`: integer.}{.} +#' \item{`away_ties`: integer.}{.} #' } #' @source \url{https://api.collegefootballdata.com/records} #' @keywords Team Info @@ -885,14 +893,10 @@ cfbd_game_player_stats <- function(year, #' @import dplyr #' @import tidyr #' @export -#' @examples -#' \donttest{ -#' cfbd_game_records(2018, team = "Notre Dame") -#' -#' cfbd_game_records(2013, team = "Florida State") -#' } -#' -cfbd_game_records <- function(year, team = NULL, conference = NULL, + +cfbd_game_records <- function(year, + team = NULL, + conference = NULL, verbose = FALSE) { @@ -981,8 +985,6 @@ cfbd_game_records <- function(year, team = NULL, conference = NULL, -#' Get Team Statistics by Game -#' #' @rdname cfbd_games #' @param year (\emph{Integer} required): Year, 4 digit format (\emph{YYYY}) #' @param week (\emph{Integer} optional): Week - values range from 1-15, 1-14 for seasons pre-playoff, i.e. 2013 or earlier @@ -992,90 +994,90 @@ cfbd_game_records <- function(year, team = NULL, conference = NULL, #' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr #' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC\cr #' @param game_id (\emph{Integer} optional): Game ID filter for querying a single game\cr -#' Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function +#' Can be found using the [cfbd_game_info()] function #' @param rows_per_team (\emph{Integer} default 1): Both Teams for each game on one or two row(s), Options: 1 or 2 #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_game_team_stats]{cfbfastR::cfbd_game_team_stats()}} - A data frame with 78 variables: +#' @return [cfbd_game_team_stats()] - A data frame with 78 variables: #' \describe{ -#' \item{\code{game_id}}{integer.} -#' \item{\code{school}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{home_away}}{character.} -#' \item{\code{points}}{integer.} -#' \item{\code{total_yards}}{character.} -#' \item{\code{net_passing_yards}}{character.} -#' \item{\code{completion_attempts}}{character.} -#' \item{\code{passing_tds}}{character.} -#' \item{\code{yards_per_pass}}{character.} -#' \item{\code{passes_intercepted}}{character.} -#' \item{\code{interception_yards}}{character.} -#' \item{\code{interception_tds}}{character.} -#' \item{\code{rushing_attempts}}{character.} -#' \item{\code{rushing_yards}}{character.} -#' \item{\code{rush_tds}}{character.} -#' \item{\code{yards_per_rush_attempt}}{character.} -#' \item{\code{first_downs}}{character.} -#' \item{\code{third_down_eff}}{character.} -#' \item{\code{fourth_down_eff}}{character.} -#' \item{\code{punt_returns}}{character.} -#' \item{\code{punt_return_yards}}{character.} -#' \item{\code{punt_return_tds}}{character.} -#' \item{\code{kick_return_yards}}{character.} -#' \item{\code{kick_return_tds}}{character.} -#' \item{\code{kick_returns}}{character.} -#' \item{\code{kicking_points}}{character.} -#' \item{\code{fumbles_recovered}}{character.} -#' \item{\code{fumbles_lost}}{character.} -#' \item{\code{total_fumbles}}{character.} -#' \item{\code{tackles}}{character.} -#' \item{\code{tackles_for_loss}}{character.} -#' \item{\code{sacks}}{character.} -#' \item{\code{qb_hurries}}{character.} -#' \item{\code{interceptions}}{character.} -#' \item{\code{passes_deflected}}{character.} -#' \item{\code{turnovers}}{character.} -#' \item{\code{defensive_tds}}{character.} -#' \item{\code{total_penalties_yards}}{character.} -#' \item{\code{possession_time}}{character.} -#' \item{\code{conference_allowed}}{character.} -#' \item{\code{home_away_allowed}}{character.} -#' \item{\code{points_allowed}}{integer.} -#' \item{\code{total_yards_allowed}}{character.} -#' \item{\code{net_passing_yards_allowed}}{character.} -#' \item{\code{completion_attempts_allowed}}{character.} -#' \item{\code{passing_tds_allowed}}{character.} -#' \item{\code{yards_per_pass_allowed}}{character.} -#' \item{\code{passes_intercepted_allowed}}{character.} -#' \item{\code{interception_yards_allowed}}{character.} -#' \item{\code{interception_tds_allowed}}{character.} -#' \item{\code{rushing_attempts_allowed}}{character.} -#' \item{\code{rushing_yards_allowed}}{character.} -#' \item{\code{rush_tds_allowed}}{character.} -#' \item{\code{yards_per_rush_attempt_allowed}}{character.} -#' \item{\code{first_downs_allowed}}{character.} -#' \item{\code{third_down_eff_allowed}}{character.} -#' \item{\code{fourth_down_eff_allowed}}{character.} -#' \item{\code{punt_returns_allowed}}{character.} -#' \item{\code{punt_return_yards_allowed}}{character.} -#' \item{\code{punt_return_tds_allowed}}{character.} -#' \item{\code{kick_return_yards_allowed}}{character.} -#' \item{\code{kick_return_tds_allowed}}{character.} -#' \item{\code{kick_returns_allowed}}{character.} -#' \item{\code{kicking_points_allowed}}{character.} -#' \item{\code{fumbles_recovered_allowed}}{character.} -#' \item{\code{fumbles_lost_allowed}}{character.} -#' \item{\code{total_fumbles_allowed}}{character.} -#' \item{\code{tackles_allowed}}{character.} -#' \item{\code{tackles_for_loss_allowed}}{character.} -#' \item{\code{sacks_allowed}}{character.} -#' \item{\code{qb_hurries_allowed}}{character.} -#' \item{\code{interceptions_allowed}}{character.} -#' \item{\code{passes_deflected_allowed}}{character.} -#' \item{\code{turnovers_allowed}}{character.} -#' \item{\code{defensive_tds_allowed}}{character.} -#' \item{\code{total_penalties_yards_allowed}}{character.} -#' \item{\code{possession_time_allowed}}{character.} +#' \item{`game_id`: integer.}{.} +#' \item{`school`: character.}{.} +#' \item{`conference`: character.}{.} +#' \item{`home_away`: character.}{.} +#' \item{`points`: integer.}{.} +#' \item{`total_yards`: character.}{.} +#' \item{`net_passing_yards`: character.}{.} +#' \item{`completion_attempts`:character.}{.} +#' \item{`passing_tds`: character.}{.} +#' \item{`yards_per_pass`: character.}{.} +#' \item{`passes_intercepted`: character.}{.} +#' \item{`interception_yards`: character.}{.} +#' \item{`interception_tds`: character.}{.} +#' \item{`rushing_attempts`: character.}{.} +#' \item{`rushing_yards`: character.}{.} +#' \item{`rush_tds`: character.}{.} +#' \item{`yards_per_rush_attempt`: character.}{.} +#' \item{`first_downs`: character.}{.} +#' \item{`third_down_eff`: character.}{.} +#' \item{`fourth_down_eff`: character.}{.} +#' \item{`punt_returns`: character.}{.} +#' \item{`punt_return_yards`: character.}{.} +#' \item{`punt_return_tds`: character.}{.} +#' \item{`kick_return_yards`: character.}{.} +#' \item{`kick_return_tds`: character.}{.} +#' \item{`kick_returns`: character.}{.} +#' \item{`kicking_points`: character.}{.} +#' \item{`fumbles_recovered`: character.}{.} +#' \item{`fumbles_lost`: character.}{.} +#' \item{`total_fumbles`: character.}{.} +#' \item{`tackles`: character.}{.} +#' \item{`tackles_for_loss`: character.}{.} +#' \item{`sacks`: character.}{.} +#' \item{`qb_hurries`: character.}{.} +#' \item{`interceptions`: character.}{.} +#' \item{`passes_deflected`: character.}{.} +#' \item{`turnovers`: character.}{.} +#' \item{`defensive_tds`: character.}{.} +#' \item{`total_penalties_yards`: character.}{.} +#' \item{`possession_time`: character.}{.} +#' \item{`conference_allowed`: character.}{.} +#' \item{`home_away_allowed`: character.}{.} +#' \item{`points_allowed`: integer.}{.} +#' \item{`total_yards_allowed`: character.}{.} +#' \item{`net_passing_yards_allowed`: character.}{.} +#' \item{`completion_attempts_allowed`: character.}{.} +#' \item{`passing_tds_allowed`: character.}{.} +#' \item{`yards_per_pass_allowed`: character.}{.} +#' \item{`passes_intercepted_allowed`: character.}{.} +#' \item{`interception_yards_allowed`: character.}{.} +#' \item{`interception_tds_allowed`: character.}{.} +#' \item{`rushing_attempts_allowed`: character.}{.} +#' \item{`rushing_yards_allowed`: character.}{.} +#' \item{`rush_tds_allowed`: character.}{.} +#' \item{`yards_per_rush_attempt_allowed`: character.}{.} +#' \item{`first_downs_allowed`: character.}{.} +#' \item{`third_down_eff_allowed`: character.}{.} +#' \item{`fourth_down_eff_allowed`: character.}{.} +#' \item{`punt_returns_allowed`: character.}{.} +#' \item{`punt_return_yards_allowed`: character.}{.} +#' \item{`punt_return_tds_allowed`: character.}{.} +#' \item{`kick_return_yards_allowed`: character.}{.} +#' \item{`kick_return_tds_allowed`: character.}{.} +#' \item{`kick_returns_allowed`: character.}{.} +#' \item{`kicking_points_allowed`: character.}{.} +#' \item{`fumbles_recovered_allowed`: character.}{.} +#' \item{`fumbles_lost_allowed`: character.}{.} +#' \item{`total_fumbles_allowed`:character.}{.} +#' \item{`tackles_allowed`:character.}{.} +#' \item{`tackles_for_loss_allowed`: character.}{.} +#' \item{`sacks_allowed`: character.}{.} +#' \item{`qb_hurries_allowed`: character.}{.} +#' \item{`interceptions_allowed`: character.}{.} +#' \item{`passes_deflected_allowed`: character.}{.} +#' \item{`turnovers_allowed`: character.}{.} +#' \item{`defensive_tds_allowed`: character.}{.} +#' \item{`total_penalties_yards_allowed`: character.}{.} +#' \item{`possession_time_allowed`: character.}{.} #' } #' @source \url{https://api.collegefootballdata.com/games/teams} #' @keywords Team Game Stats @@ -1089,13 +1091,7 @@ cfbd_game_records <- function(year, team = NULL, conference = NULL, #' @import tidyr #' @import purrr #' @export -#' @examples -#' \donttest{ -#' cfbd_game_team_stats(2019, team = "LSU") -#' -#' cfbd_game_team_stats(2013, team = "Florida State") -#' } -#' + cfbd_game_team_stats <- function(year, week = NULL, season_type = "regular", diff --git a/R/cfbd_metrics.R b/R/cfbd_metrics.R index 996f5e14..ca1b478e 100644 --- a/R/cfbd_metrics.R +++ b/R/cfbd_metrics.R @@ -1,157 +1,17 @@ -#' CFBD Metrics Endpoint -#' #' @name cfbd_metrics -NULL -#' Get team game averages for Predicted Points Added (PPA) -#' @rdname cfbd_metrics -#' -#' @param year (\emph{Integer} required): Year, 4 digit format (\emph{YYYY}) -#' @param week (\emph{Integer} optional): Week - values range from 1-15, 1-14 for seasons pre-playoff, i.e. 2013 or earlier -#' @param team (\emph{String} optional): D-I Team -#' @param conference (\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr -#' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr -#' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC\cr -#' @param excl_garbage_time (\emph{Logical} default FALSE): Select whether to exclude Garbage Time (TRUE or FALSE) -#' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' -#' @return \code{\link[cfbfastR:cfbd_metrics_ppa_games]{cfbfastR::cfbd_metrics_ppa_games()}} - A data frame with 18 variables: +#' @aliases cfbd_metrics cfbd_metrics_ppa_games +#' cfbd_metrics_ppa_players_games cfbd_metrics_ppa_players_season cfbd_metrics_ppa_teams cfbd_metrics_wp_pregame cfbd_metrics_wp +#' @title CFBD Metrics Endpoint +#' @description #' \describe{ -#' \item{\code{game_id}}{integer.} -#' \item{\code{season}}{integer.} -#' \item{\code{week}}{integer.} -#' \item{\code{conference}}{character.} -#' \item{\code{team}}{character.} -#' \item{\code{opponent}}{character.} -#' \item{\code{off_overall}}{character.} -#' \item{\code{off_passing}}{character.} -#' \item{\code{off_rushing}}{character.} -#' \item{\code{off_first_down}}{character.} -#' \item{\code{off_second_down}}{character.} -#' \item{\code{off_third_down}}{character.} -#' \item{\code{def_overall}}{character.} -#' \item{\code{def_passing}}{character.} -#' \item{\code{def_rushing}}{character.} -#' \item{\code{def_first_down}}{character.} -#' \item{\code{def_second_down}}{character.} -#' \item{\code{def_third_down}}{character.} -#' } -#' @keywords Teams Predicted Points -#' @importFrom jsonlite fromJSON -#' @importFrom httr GET RETRY -#' @importFrom utils URLencode -#' @importFrom assertthat assert_that -#' @importFrom glue glue -#' @import dplyr -#' @import tidyr -#' @export -#' @examples -#' \donttest{ -#' cfbd_metrics_ppa_games(year = 2019, team = "TCU") +#' \item{`cfbd_metrics_ppa_games()`:}{Get team game averages for Predicted Points Added (PPA).} +#' \item{`cfbd_metrics_ppa_players_games()`:}{Get player game averages for Predicted Points Added (PPA).} +#' \item{`cfbd_metrics_ppa_players_season()`:}{Get player season averages for Predicted Points Added (PPA).} +#' \item{`cfbd_metrics_ppa_predicted()`:}{Calculate Predicted Points using Down and Distance.} +#' \item{`cfbd_metrics_ppa_teams()`:}{Get team averages for Predicted Points Added (PPA).} +#' \item{`cfbd_metrics_wp_pregame()`:}{Get Pre-game Win Probability Data from CFBD API.} +#' \item{`cfbd_metrics_wp()`:}{Get win probability chart data from CFBD API.} #' } -#' -cfbd_metrics_ppa_games <- function(year, - week = NULL, - team = NULL, - conference = NULL, - excl_garbage_time = FALSE, - verbose = FALSE) { - args <- list(year = year) - - ## check if year is numeric - assertthat::assert_that(is.numeric(year) & nchar(year) == 4, - msg = "Enter valid year as integer in 4 digit format (YYYY)" - ) - - if (!is.null(week)) { - # Check if week is numeric, if not NULL - assertthat::assert_that(is.numeric(week) & nchar(week) <= 2, - msg = "Enter valid week (Integer): 1-15\n(14 for seasons pre-playoff, i.e. 2014 or earlier)" - ) - } - if (!is.null(team)) { - if (team == "San Jose State") { - team <- utils::URLencode(paste0("San Jos", "\u00e9", " State"), reserved = TRUE) - } else { - # Encode team parameter for URL if not NULL - team <- utils::URLencode(team, reserved = TRUE) - } - } - if (!is.null(conference)) { - # # Check conference parameter in conference abbreviations, if not NULL - # assertthat::assert_that(conference %in% cfbfastR::cfbd_conf_types_df$abbreviation, - # msg = "Incorrect conference abbreviation, potential misspelling.\nConference abbreviations P5: ACC, B12, B1G, SEC, PAC\nConference abbreviations G5 and Independents: CUSA, MAC, MWC, Ind, SBC, AAC") - # Encode conference parameter for URL, if not NULL - conference <- utils::URLencode(conference, reserved = TRUE) - } - if (excl_garbage_time != FALSE) { - # Check if excl_garbage_time is TRUE, if not FALSE - assertthat::assert_that(excl_garbage_time == TRUE, - msg = "Enter valid excl_garbage_time value (Logical) - TRUE or FALSE" - ) - } - - base_url <- "https://api.collegefootballdata.com/ppa/games?" - - full_url <- paste0( - base_url, - "year=", year, - "&week=", week, - "&team=", team, - "&conference=", conference, - "&excludeGarbageTime=", excl_garbage_time - ) - - # Check for internet - check_internet() - - # Check for CFBD API key - if (!has_cfbd_key()) stop("CollegeFootballData.com now requires an API key.", "\n See ?register_cfbd for details.", call. = FALSE) - - # Create the GET request and set response as res - res <- httr::RETRY( - "GET", full_url, - httr::add_headers(Authorization = paste("Bearer", cfbd_key())) - ) - - # Check the result - check_status(res) - - df <- data.frame() - tryCatch( - expr = { - # Get the content, flatten and return result as data.frame - df <- res %>% - httr::content(as = "text", encoding = "UTF-8") %>% - jsonlite::fromJSON(flatten = TRUE) - colnames(df) <- gsub("offense.", "off_", colnames(df)) - colnames(df) <- gsub("defense.", "def_", colnames(df)) - colnames(df) <- gsub("Down", "_down", colnames(df)) - - df <- df %>% - dplyr::rename(game_id = .data$gameId) %>% - as.data.frame() - - if(verbose){ - message(glue::glue("{Sys.time()}: Scraping CFBData metrics PPA games data...")) - } - }, - error = function(e) { - if(verbose){ - message(glue::glue("{Sys.time()}: Invalid arguments or no CFBData metrics PPA games data available!")) - } - }, - warning = function(w) { - }, - finally = { - } - ) - return(df) -} - - -#' Get team game averages for Predicted Points Added (PPA) -#' @rdname cfbd_metrics -#' #' @param year (\emph{Integer} required): Year, 4 digit format (\emph{YYYY}) #' @param week (\emph{Integer} optional): Week - values range from 1-15, 1-14 for seasons pre-playoff, i.e. 2013 or earlier #' @param team (\emph{String} optional): D-I Team @@ -161,26 +21,26 @@ cfbd_metrics_ppa_games <- function(year, #' @param excl_garbage_time (\emph{Logical} default FALSE): Select whether to exclude Garbage Time (TRUE or FALSE) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_metrics_ppa_games]{cfbfastR::cfbd_metrics_ppa_games()}} - A data frame with 18 variables: +#' @return [cfbd_metrics_ppa_games()] - A data frame with 18 variables: #' \describe{ -#' \item{\code{game_id}}{integer.} -#' \item{\code{season}}{integer.} -#' \item{\code{week}}{integer.} -#' \item{\code{conference}}{character.} -#' \item{\code{team}}{character.} -#' \item{\code{opponent}}{character.} -#' \item{\code{off_overall}}{character.} -#' \item{\code{off_passing}}{character.} -#' \item{\code{off_rushing}}{character.} -#' \item{\code{off_first_down}}{character.} -#' \item{\code{off_second_down}}{character.} -#' \item{\code{off_third_down}}{character.} -#' \item{\code{def_overall}}{character.} -#' \item{\code{def_passing}}{character.} -#' \item{\code{def_rushing}}{character.} -#' \item{\code{def_first_down}}{character.} -#' \item{\code{def_second_down}}{character.} -#' \item{\code{def_third_down}}{character.} +#' \item{`game_id`: integer.}{Referencing game id.} +#' \item{`season`: integer.}{Season of the game.} +#' \item{`week`: integer.}{Game week of the season.} +#' \item{`conference`: character.}{Conference of the team.} +#' \item{`team`: character.}{Team name.} +#' \item{`opponent`: character.}{Team Opponent.} +#' \item{`off_overall`: character.}{Offense overall predicted points added (PPA).} +#' \item{`off_passing`: character.}{Offense passing predicted points added (PPA).} +#' \item{`off_rushing`: character.}{Offense rushing predicted points added (PPA).} +#' \item{`off_first_down`: character.}{Offense 1st down predicted points added (PPA).} +#' \item{`off_second_down`: character.}{Offense 2nd down predicted points added (PPA).} +#' \item{`off_third_down`: character.}{Offense 3rd down predicted points added (PPA).} +#' \item{`def_overall`: character.}{Defense overall predicted points added (PPA).} +#' \item{`def_passing`: character.}{Defense passing predicted points added (PPA).} +#' \item{`def_rushing`: character.}{Defense rushing predicted points added (PPA).} +#' \item{`def_first_down`: character.}{Defense 1st down predicted points added (PPA).} +#' \item{`def_second_down`: character.}{Defense 2nd down predicted points added (PPA).} +#' \item{`def_third_down`: character.}{Defense 3rd down predicted points added (PPA).} #' } #' @keywords Teams Predicted Points #' @importFrom jsonlite fromJSON @@ -306,22 +166,22 @@ cfbd_metrics_ppa_games <- function(year, #' * Defense: DB, CB, S, LB, DE, DT, NT, DL\cr #' * Special Teams: K, P, LS, PK\cr #' @param athlete_id (\emph{Integer} optional): Athlete ID filter for querying a single athlete\cr -#' Can be found using the \code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_player_info()}} function. +#' Can be found using the [cfbd_player_info()] function. #' @param threshold (\emph{Integer} optional): Minimum threshold of plays. #' @param excl_garbage_time (\emph{Logical} default FALSE): Select whether to exclude Garbage Time (TRUE or FALSE) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_metrics_ppa_players_games]{cfbfastR::cfbd_metrics_ppa_players_games()}} - A data frame with 9 variables: +#' @return [cfbd_metrics_ppa_players_games()] - A data frame with 9 variables: #' \describe{ -#' \item{\code{season}}{integer.} -#' \item{\code{week}}{integer.} -#' \item{\code{name}}{character.} -#' \item{\code{position}}{character.} -#' \item{\code{team}}{character.} -#' \item{\code{opponent}}{character.} -#' \item{\code{avg_PPA_all}}{double.} -#' \item{\code{avg_PPA_pass}}{double.} -#' \item{\code{avg_PPA_rush}}{double.} +#' \item{`season`: integer.}{Season of the game.} +#' \item{`week`: integer.}{Game week of the season.} +#' \item{`name`: character.}{Athlete name.} +#' \item{`position`: character.}{Athlete position.} +#' \item{`team`: character.}{Team name.} +#' \item{`opponent`: character.}{Team Opponent name.} +#' \item{`avg_PPA_all`: double.}{Average overall predicted points added (PPA).} +#' \item{`avg_PPA_pass`: double.}{Average passing predicted points added (PPA).} +#' \item{`avg_PPA_rush`: double.}{Average rushing predicted points added (PPA).} #' } #' @source \url{https://api.collegefootballdata.com/ppa/players/games} #' @keywords Players Predicted Points @@ -467,36 +327,36 @@ cfbd_metrics_ppa_players_games <- function(year = NULL, #' * Defense: DB, CB, S, LB, DE, DT, NT, DL\cr #' * Special Teams: K, P, LS, PK\cr #' @param athlete_id (\emph{Integer} optional): Athlete ID filter for querying a single athlete\cr -#' Can be found using the \code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_player_info()}} function. +#' Can be found using the [cfbd_player_info()] function. #' @param threshold (\emph{Integer} optional): Minimum threshold of plays. #' @param excl_garbage_time (\emph{Logical} default FALSE): Select whether to exclude Garbage Time (TRUE or FALSE) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_metrics_ppa_players_season]{cfbfastR::cfbd_metrics_ppa_players_season()}} - A data frame with 23 variables: +#' @return [cfbd_metrics_ppa_players_season()] - A data frame with 23 variables: #' \describe{ -#' \item{\code{season}}{integer.} -#' \item{\code{id}}{character.} -#' \item{\code{name}}{character.} -#' \item{\code{position}}{character.} -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{countable_plays}}{integer.} -#' \item{\code{avg_PPA_all}}{double.} -#' \item{\code{avg_PPA_pass}}{double.} -#' \item{\code{avg_PPA_rush}}{double.} -#' \item{\code{avg_PPA_first_down}}{double.} -#' \item{\code{avg_PPA_second_down}}{double.} -#' \item{\code{avg_PPA_third_down}}{double.} -#' \item{\code{avg_PPA_standard_downs}}{double.} -#' \item{\code{avg_PPA_passing_downs}}{double.} -#' \item{\code{total_PPA_all}}{double.} -#' \item{\code{total_PPA_pass}}{double.} -#' \item{\code{total_PPA_rush}}{double.} -#' \item{\code{total_PPA_first_down}}{double.} -#' \item{\code{total_PPA_second_down}}{double.} -#' \item{\code{total_PPA_third_down}}{double.} -#' \item{\code{total_PPA_standard_downs}}{double.} -#' \item{\code{total_PPA_passing_downs}}{double.} +#' \item{`season`: integer.}{Season.} +#' \item{`athlete_id`: character.}{Athlete referencing id.} +#' \item{`name`: character.}{Athlete name.} +#' \item{`position`: character.}{Athlete Position.} +#' \item{`team`: character.}{Team name.} +#' \item{`conference`: character.}{Team conference.} +#' \item{`countable_plays`: integer.}{Number of plays which can be counted.} +#' \item{`avg_PPA_all`: double.}{Average overall predicted points added (PPA).} +#' \item{`avg_PPA_pass`: double.}{Average passing predicted points added (PPA).} +#' \item{`avg_PPA_rush`: double.}{Average rushing predicted points added (PPA).} +#' \item{`avg_PPA_first_down`: double.}{Average 1st down predicted points added (PPA).} +#' \item{`avg_PPA_second_down`: double.}{Average 2nd down predicted points added (PPA).} +#' \item{`avg_PPA_third_down`: double.}{Average 3rd down predicted points added (PPA).} +#' \item{`avg_PPA_standard_downs`: double.}{Average standard down predicted points added (PPA).} +#' \item{`avg_PPA_passing_downs`: double.}{Average passing down predicted points added (PPA).} +#' \item{`total_PPA_all`: double.}{Total overall predicted points added (PPA).} +#' \item{`total_PPA_pass`: double.}{Total passing predicted points added (PPA).} +#' \item{`total_PPA_rush`: double.}{Total rushing predicted points added (PPA).} +#' \item{`total_PPA_first_down`: double.}{Total 1st down predicted points added (PPA).} +#' \item{`total_PPA_second_down`: double.}{Total 2nd down predicted points added (PPA).} +#' \item{`total_PPA_third_down`: double.}{Total 3rd down predicted points added (PPA).} +#' \item{`total_PPA_standard_downs`: double.}{Total standard down predicted points added (PPA).} +#' \item{`total_PPA_passing_downs`: double.}{Total passing down predicted points added (PPA).} #' } #' @source \url{https://api.collegefootballdata.com/ppa/players/season} #' @keywords Players Predicted Points Season Averages @@ -612,7 +472,8 @@ cfbd_metrics_ppa_players_season <- function(year = NULL, colnames(df) <- gsub("countablePlays", "countable_plays", colnames(df)) colnames(df) <- gsub("Down", "_down", colnames(df)) - df <- df %>% + df <- df %>% + dplyr::rename(athlete_id = .data$id) %>% dplyr::arrange(-.data$countable_plays) %>% as.data.frame() @@ -642,10 +503,10 @@ cfbd_metrics_ppa_players_season <- function(year = NULL, #' @param distance (\emph{Integer} required): Distance filter #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_metrics_ppa_predicted]{cfbfastR::cfbd_metrics_ppa_predicted()}} - A data frame with 2 variables: +#' @return [cfbd_metrics_ppa_predicted()] - A data frame with 2 variables: #' \describe{ -#' \item{\code{yard_line}}{integer.} -#' \item{\code{predicted_points}}{character.} +#' \item{`yard_line`: integer.}{Yards to goal} +#' \item{`predicted_points`: character.}{Predicted points at in that down-distance-yardline scenario} #' } #' @source \url{https://api.collegefootballdata.com/ppa/predicted} #' @keywords Predicted Points @@ -735,29 +596,29 @@ cfbd_metrics_ppa_predicted <- function(down, #' @param excl_garbage_time (\emph{Logical} default FALSE): Select whether to exclude Garbage Time (TRUE or FALSE) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_metrics_ppa_teams]{cfbfastR::cfbd_metrics_ppa_teams()}} - A data frame with 21 variables: +#' @return [cfbd_metrics_ppa_teams()] - A data frame with 21 variables: #' \describe{ -#' \item{\code{season}}{integer.} -#' \item{\code{conference}}{character.} -#' \item{\code{team}}{character.} -#' \item{\code{off_overall}}{character.} -#' \item{\code{off_passing}}{character.} -#' \item{\code{off_rushing}}{character.} -#' \item{\code{off_first_down}}{character.} -#' \item{\code{off_second_down}}{character.} -#' \item{\code{off_third_down}}{character.} -#' \item{\code{off_cumulative_total}}{character.} -#' \item{\code{off_cumulative_passing}}{character.} -#' \item{\code{off_cumulative_rushing}}{character.} -#' \item{\code{def_overall}}{character.} -#' \item{\code{def_passing}}{character.} -#' \item{\code{def_rushing}}{character.} -#' \item{\code{def_first_down}}{character.} -#' \item{\code{def_second_down}}{character.} -#' \item{\code{def_third_down}}{character.} -#' \item{\code{def_cumulative_total}}{character.} -#' \item{\code{def_cumulative_passing}}{character.} -#' \item{\code{def_cumulative_rushing}}{character.} +#' \item{`season`: integer.}{.} +#' \item{`conference`: character.}{.} +#' \item{`team`: character.}{.} +#' \item{`off_overall`: character.}{Offense overall predicted points added (PPA).} +#' \item{`off_passing`: character.}{Offense passing predicted points added (PPA).} +#' \item{`off_rushing`: character.}{Offense rushing predicted points added (PPA).} +#' \item{`off_first_down`: character.}{Offense 1st down predicted points added (PPA).} +#' \item{`off_second_down`: character.}{Offense 2nd down predicted points added (PPA).} +#' \item{`off_third_down`: character.}{Offense 3rd down predicted points added (PPA).} +#' \item{`off_cumulative_total`: character.}{Offense cumulative total predicted points added (PPA).} +#' \item{`off_cumulative_passing`: character.}{Offense cumulative total passing predicted points added (PPA).} +#' \item{`off_cumulative_rushing`: character.}{Offense cumulative total rushing predicted points added (PPA).} +#' \item{`def_overall`: character.}{Defense overall predicted points added (PPA).} +#' \item{`def_passing`: character.}{Defense passing predicted points added (PPA).} +#' \item{`def_rushing`: character.}{Defense rushing predicted points added (PPA).} +#' \item{`def_first_down`: character.}{Defense 1st down predicted points added (PPA).} +#' \item{`def_second_down`: character.}{Defense 2nd down predicted points added (PPA).} +#' \item{`def_third_down`: character.}{Defense 3rd down predicted points added (PPA).} +#' \item{`def_cumulative_total`: character.}{Defense cumulative total predicted points added (PPA).} +#' \item{`def_cumulative_passing`: character.}{Defense cumulative total passing predicted points added (PPA).} +#' \item{`def_cumulative_rushing`: character.}{Defense cumulative total rushing predicted points added (PPA).} #' } #' @source \url{https://api.collegefootballdata.com/ppa/teams} #' @keywords Teams Predicted Points @@ -870,17 +731,17 @@ cfbd_metrics_ppa_teams <- function(year = 2019, #' @param season_type (\emph{String} default regular): Select Season Type: regular or postseason #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_metrics_wp_pregame]{cfbfastR::cfbd_metrics_wp_pregame()}} - A data frame with 9 variables: +#' @return [cfbd_metrics_wp_pregame()] - A data frame with 9 variables: #' \describe{ -#' \item{\code{season}}{integer.} -#' \item{\code{season_type}}{character.} -#' \item{\code{week}}{integer.} -#' \item{\code{game_id}}{integer.} -#' \item{\code{home_team}}{character.} -#' \item{\code{away_team}}{character.} -#' \item{\code{spread}}{integer.} -#' \item{\code{home_win_prob}}{double.} -#' \item{\code{away_win_prob}}{double.} +#' \item{`season`: integer.}{Season of game.} +#' \item{`season_type`: character.}{Season type of game.} +#' \item{`week`: integer.}{Game week of the season.} +#' \item{`game_id`: integer.}{Referencing game id.} +#' \item{`home_team`: character.}{Home team name.} +#' \item{`away_team`: character.}{Away team name.} +#' \item{`spread`: integer.}{Betting line provider spread.} +#' \item{`home_win_prob`: double.}{Home win probability - pre-game prediction.} +#' \item{`away_win_prob`: double.}{Away win probability - pre-game prediction.} #' } #' @keywords Pre-game Win Probability Data #' @importFrom jsonlite fromJSON @@ -985,27 +846,27 @@ cfbd_metrics_wp_pregame <- function(year = NULL, #' @rdname cfbd_metrics #' #' @param game_id (\emph{Integer} required): Game ID filter for querying a single game\cr -#' Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function +#' Can be found using the [cfbd_game_info()] function #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_metrics_wp]{cfbfastR::cfbd_metrics_wp()}} - A data frame with 16 variables: +#' @return [cfbd_metrics_wp()] - A data frame with 16 variables: #' \describe{ -#' \item{\code{play_id}}{character.} -#' \item{\code{play_text}}{character.} -#' \item{\code{home_id}}{integer.} -#' \item{\code{home}}{character.} -#' \item{\code{away_id}}{integer.} -#' \item{\code{away}}{character.} -#' \item{\code{spread}}{character.} -#' \item{\code{home_ball}}{logical.} -#' \item{\code{home_score}}{integer.} -#' \item{\code{away_score}}{integer.} -#' \item{\code{down}}{integer.} -#' \item{\code{distance}}{integer.} -#' \item{\code{home_win_prob}}{character.} -#' \item{\code{away_win_prob}}{double.} -#' \item{\code{play_number}}{integer.} -#' \item{\code{yard_line}}{integer.} +#' \item{`play_id`: character.}{Play referencing id.} +#' \item{`play_text`: character.}{A text description of the play.} +#' \item{`home_id`: integer.}{Home team referencing id.} +#' \item{`home`: character.}{Home team name.} +#' \item{`away_id`: integer.}{Away team referencing id.} +#' \item{`away`: character.}{Away team name.} +#' \item{`spread`: character.}{Betting lines provider spread.} +#' \item{`home_ball`: logical.}{Home team has the ball.} +#' \item{`home_score`: integer.}{Home team score.} +#' \item{`away_score`: integer.}{Away team score.} +#' \item{`down`: integer.}{Down of the play.} +#' \item{`distance`: integer.}{Distance to the sticks (to 1st down marker of goal-line in goal-to-go situations).} +#' \item{`home_win_prob`: character.}{Home team win probability.} +#' \item{`away_win_prob`: double.}{Away team win probability.} +#' \item{`play_number`: integer.}{Game play number.} +#' \item{`yard_line`: integer.}{Yard line of the play (0-100 yards).} #' } #' @source \url{https://api.collegefootballdata.com/metrics/wp} #' @keywords Win Probability Chart Data diff --git a/R/cfbd_pbp_data.R b/R/cfbd_pbp_data.R index a5596936..cde4af21 100644 --- a/R/cfbd_pbp_data.R +++ b/R/cfbd_pbp_data.R @@ -1,371 +1,369 @@ -#' CFBD Play by Play Data -#' #' @name cfbd_pbp_data -NULL -#' Extract CFB (D-I) Play by Play Data - For plays -#' @rdname cfbd_pbp_data +#' @aliases play-by-play pbp_data cfbd_pbp_data +#' @title CFBD Play by Play Data +#' @description Extract CFB (D-I) Play by Play Data - For plays #' @source \url{https://api.collegefootballdata.com/plays} #' @param season_type Select Season Type (regular, postseason, both) #' @param year Select year, (example: 2018) #' @param week Select week, this is optional (also numeric) #' @param team Select team name (example: Texas, Texas A&M, Clemson) -#' @param play_type Select play type (example: see the \code{\link[cfbfastR:cfbd_play_type_df]{cfbd_play_type_df}}) +#' @param play_type Select play type (example: see the [cfbd_play_type_df]) #' @param epa_wpa Logical parameter (TRUE/FALSE) to return the Expected Points Added/Win Probability Added variables #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' @param ... Additional arguments passed to an underlying function. #' @return A data frame with 351 variables: #' \describe{ -#' \item{\code{year}}{double.} -#' \item{\code{week}}{double.} -#' \item{\code{id_play}}{character.} -#' \item{\code{game_id}}{integer.} -#' \item{\code{game_play_number}}{double.} -#' \item{\code{half_play_number}}{double.} -#' \item{\code{pos_team}}{character.} -#' \item{\code{def_pos_team}}{character.} -#' \item{\code{half}}{integer.} -#' \item{\code{period}}{integer.} -#' \item{\code{clock.minutes}}{integer.} -#' \item{\code{clock.seconds}}{integer.} -#' \item{\code{play_type}}{character.} -#' \item{\code{play_text}}{character.} -#' \item{\code{down}}{double.} -#' \item{\code{distance}}{double.} -#' \item{\code{yards_to_goal}}{double.} -#' \item{\code{yards_gained}}{double.} -#' \item{\code{penalty_1st_conv}}{logical.} -#' \item{\code{new_series}}{double.} -#' \item{\code{change_of_pos_team}}{double.} -#' \item{\code{lag_change_of_pos_team}}{double.} -#' \item{\code{orig_play_type}}{character.} -#' \item{\code{lead_play_type}}{character.} -#' \item{\code{lag_play_type}}{character.} -#' \item{\code{lag_play_type2}}{character.} -#' \item{\code{lag_play_type3}}{character.} -#' \item{\code{row}}{integer.} -#' \item{\code{drive_play_number}}{double.} -#' \item{\code{drive_event_number}}{double.} -#' \item{\code{lag_play_text}}{character.} -#' \item{\code{lag_play_text2}}{character.} -#' \item{\code{lead_play_text}}{character.} -#' \item{\code{firstD_by_kickoff}}{double.} -#' \item{\code{firstD_by_poss}}{double.} -#' \item{\code{firstD_by_penalty}}{double.} -#' \item{\code{firstD_by_yards}}{double.} -#' \item{\code{lag_first_by_penalty}}{double.} -#' \item{\code{lag_first_by_penalty2}}{double.} -#' \item{\code{lag_first_by_yards}}{double.} -#' \item{\code{lag_first_by_yards2}}{double.} -#' \item{\code{first_by_penalty}}{double.} -#' \item{\code{first_by_yards}}{double.} -#' \item{\code{play_after_turnover}}{double.} -#' \item{\code{lag_change_of_poss}}{double.} -#' \item{\code{lag_kickoff_play}}{double.} -#' \item{\code{lag_punt}}{double.} -#' \item{\code{lag_scoring_play}}{double.} -#' \item{\code{lag_turnover_vec}}{double.} -#' \item{\code{lag_downs_turnover}}{double.} -#' \item{\code{lag_defense_score_play}}{double.} -#' \item{\code{EPA}}{double.} -#' \item{\code{ep_before}}{double.} -#' \item{\code{ep_after}}{double.} -#' \item{\code{wpa}}{double.} -#' \item{\code{wp_before}}{double.} -#' \item{\code{wp_after}}{double.} -#' \item{\code{def_wp_before}}{double.} -#' \item{\code{def_wp_after}}{double.} -#' \item{\code{penalty_detail}}{character.} -#' \item{\code{yds_penalty}}{double.} -#' \item{\code{downs_turnover}}{double.} -#' \item{\code{turnover}}{double.} -#' \item{\code{pos_score_diff_start}}{double.} -#' \item{\code{pos_score_pts}}{double.} -#' \item{\code{pos_team_score}}{integer.} -#' \item{\code{def_pos_team_score}}{integer.} -#' \item{\code{log_ydstogo}}{double.} -#' \item{\code{ExpScoreDiff}}{double.} -#' \item{\code{ExpScoreDiff_Time_Ratio}}{double.} -#' \item{\code{half_clock.minutes}}{double.} -#' \item{\code{TimeSecsRem}}{double.} -#' \item{\code{adj_TimeSecsRem}}{double.} -#' \item{\code{Goal_To_Go}}{logical.} -#' \item{\code{Under_two}}{logical.} -#' \item{\code{home}}{character.} -#' \item{\code{away}}{character.} -#' \item{\code{home_wp_before}}{double.} -#' \item{\code{away_wp_before}}{double.} -#' \item{\code{home_wp_after}}{double.} -#' \item{\code{away_wp_after}}{double.} -#' \item{\code{end_of_half}}{double.} -#' \item{\code{pos_team_receives_2H_kickoff}}{double.} -#' \item{\code{lead_pos_team}}{character.} -#' \item{\code{lag_pos_team}}{character.} -#' \item{\code{Under_three}}{logical.} -#' \item{\code{down_end}}{integer.} -#' \item{\code{distance_end}}{double.} -#' \item{\code{log_ydstogo_end}}{double.} -#' \item{\code{yards_to_goal_end}}{double.} -#' \item{\code{TimeSecsRem_end}}{double.} -#' \item{\code{Goal_To_Go_end}}{logical.} -#' \item{\code{Under_two_end}}{logical.} -#' \item{\code{def_EPA}}{double.} -#' \item{\code{offense_score_play}}{double.} -#' \item{\code{defense_score_play}}{double.} -#' \item{\code{ppa}}{character.} -#' \item{\code{yard_line}}{integer.} -#' \item{\code{scoring}}{logical.} -#' \item{\code{pos_team_timeouts_rem_before}}{double.} -#' \item{\code{def_pos_team_timeouts_rem_before}}{double.} -#' \item{\code{pos_team_timeouts}}{integer.} -#' \item{\code{def_pos_team_timeouts}}{integer.} -#' \item{\code{pos_score_diff}}{integer.} -#' \item{\code{pos_score_diff_start_end}}{double.} -#' \item{\code{offense_play}}{character.} -#' \item{\code{defense_play}}{character.} -#' \item{\code{offense_receives_2H_kickoff}}{double.} -#' \item{\code{change_of_poss}}{double.} -#' \item{\code{score_pts}}{double.} -#' \item{\code{score_diff_start}}{double.} -#' \item{\code{score_diff}}{integer.} -#' \item{\code{offense_score}}{integer.} -#' \item{\code{defense_score}}{integer.} -#' \item{\code{offense_conference}}{character.} -#' \item{\code{defense_conference}}{character.} -#' \item{\code{off_timeout_called}}{double.} -#' \item{\code{def_timeout_called}}{double.} -#' \item{\code{offense_timeouts}}{integer.} -#' \item{\code{defense_timeouts}}{integer.} -#' \item{\code{off_timeouts_rem_before}}{double.} -#' \item{\code{def_timeouts_rem_before}}{double.} -#' \item{\code{rusher_player_name}}{character.} -#' \item{\code{yds_rushed}}{double.} -#' \item{\code{passer_player_name}}{character.} -#' \item{\code{receiver_player_name}}{character.} -#' \item{\code{yds_receiving}}{double.} -#' \item{\code{yds_sacked}}{double.} -#' \item{\code{sack_players}}{character.} -#' \item{\code{sack_player_name}}{character.} -#' \item{\code{sack_player_name2}}{character.} -#' \item{\code{pass_breakup_player_name}}{character.} -#' \item{\code{interception_player_name}}{character.} -#' \item{\code{yds_int_return}}{double.} -#' \item{\code{fumble_player_name}}{character.} -#' \item{\code{fumble_forced_player_name}}{character.} -#' \item{\code{fumble_recovered_player_name}}{character.} -#' \item{\code{yds_fumble_return}}{double.} -#' \item{\code{punter_player_name}}{character.} -#' \item{\code{yds_punted}}{double.} -#' \item{\code{punt_returner_player_name}}{character.} -#' \item{\code{yds_punt_return}}{double.} -#' \item{\code{yds_punt_gained}}{double.} -#' \item{\code{punt_block_player_name}}{character.} -#' \item{\code{punt_block_return_player_name}}{character.} -#' \item{\code{fg_kicker_player_name}}{character.} -#' \item{\code{yds_fg}}{double.} -#' \item{\code{fg_block_player_name}}{character.} -#' \item{\code{fg_return_player_name}}{character.} -#' \item{\code{kickoff_player_name}}{character.} -#' \item{\code{yds_kickoff}}{double.} -#' \item{\code{kickoff_returner_player_name}}{character.} -#' \item{\code{yds_kickoff_return}}{double.} -#' \item{\code{new_id}}{double.} -#' \item{\code{orig_drive_number}}{integer.} -#' \item{\code{drive_number}}{integer.} -#' \item{\code{drive_result_detailed}}{character.} -#' \item{\code{new_drive_pts}}{double.} -#' \item{\code{drive_id}}{double.} -#' \item{\code{drive_result}}{character.} -#' \item{\code{drive_start_yards_to_goal}}{double.} -#' \item{\code{drive_end_yards_to_goal}}{integer.} -#' \item{\code{drive_yards}}{integer.} -#' \item{\code{drive_scoring}}{double.} -#' \item{\code{drive_pts}}{double.} -#' \item{\code{drive_start_period}}{integer.} -#' \item{\code{drive_end_period}}{integer.} -#' \item{\code{drive_time_minutes_start}}{integer.} -#' \item{\code{drive_time_seconds_start}}{integer.} -#' \item{\code{drive_time_minutes_end}}{integer.} -#' \item{\code{drive_time_seconds_end}}{integer.} -#' \item{\code{drive_time_minutes_elapsed}}{integer.} -#' \item{\code{drive_time_seconds_elapsed}}{integer.} -#' \item{\code{drive_numbers}}{double.} -#' \item{\code{number_of_drives}}{double.} -#' \item{\code{pts_scored}}{double.} -#' \item{\code{drive_result_detailed_flag}}{character.} -#' \item{\code{drive_result2}}{character.} -#' \item{\code{drive_num}}{double.} -#' \item{\code{lag_drive_result_detailed}}{character.} -#' \item{\code{lead_drive_result_detailed}}{character.} -#' \item{\code{lag_new_drive_pts}}{double.} -#' \item{\code{id_drive}}{character.} -#' \item{\code{rush}}{double.} -#' \item{\code{rush_td}}{double.} -#' \item{\code{pass}}{double.} -#' \item{\code{pass_td}}{double.} -#' \item{\code{completion}}{double.} -#' \item{\code{pass_attempt}}{double.} -#' \item{\code{target}}{double.} -#' \item{\code{sack_vec}}{double.} -#' \item{\code{sack}}{double.} -#' \item{\code{int}}{double.} -#' \item{\code{int_td}}{double.} -#' \item{\code{turnover_vec}}{double.} -#' \item{\code{turnover_vec_lag}}{double.} -#' \item{\code{turnover_indicator}}{double.} -#' \item{\code{kickoff_play}}{double.} -#' \item{\code{receives_2H_kickoff}}{double.} -#' \item{\code{missing_yard_flag}}{logical.} -#' \item{\code{scoring_play}}{double.} -#' \item{\code{td_play}}{double.} -#' \item{\code{touchdown}}{double.} -#' \item{\code{safety}}{double.} -#' \item{\code{fumble_vec}}{double.} -#' \item{\code{kickoff_tb}}{double.} -#' \item{\code{kickoff_onside}}{double.} -#' \item{\code{kickoff_oob}}{double.} -#' \item{\code{kickoff_fair_catch}}{double.} -#' \item{\code{kickoff_downed}}{double.} -#' \item{\code{kickoff_safety}}{double.} -#' \item{\code{kick_play}}{double.} -#' \item{\code{punt}}{double.} -#' \item{\code{punt_play}}{double.} -#' \item{\code{punt_tb}}{double.} -#' \item{\code{punt_oob}}{double.} -#' \item{\code{punt_fair_catch}}{double.} -#' \item{\code{punt_downed}}{double.} -#' \item{\code{punt_safety}}{double.} -#' \item{\code{punt_blocked}}{double.} -#' \item{\code{penalty_safety}}{double.} -#' \item{\code{fg_inds}}{double.} -#' \item{\code{fg_made}}{logical.} -#' \item{\code{fg_make_prob}}{double.} -#' \item{\code{home_EPA}}{double.} -#' \item{\code{away_EPA}}{double.} -#' \item{\code{home_EPA_rush}}{double.} -#' \item{\code{away_EPA_rush}}{double.} -#' \item{\code{home_EPA_pass}}{double.} -#' \item{\code{away_EPA_pass}}{double.} -#' \item{\code{total_home_EPA}}{double.} -#' \item{\code{total_away_EPA}}{double.} -#' \item{\code{total_home_EPA_rush}}{double.} -#' \item{\code{total_away_EPA_rush}}{double.} -#' \item{\code{total_home_EPA_pass}}{double.} -#' \item{\code{total_away_EPA_pass}}{double.} -#' \item{\code{net_home_EPA}}{double.} -#' \item{\code{net_away_EPA}}{double.} -#' \item{\code{net_home_EPA_rush}}{double.} -#' \item{\code{net_away_EPA_rush}}{double.} -#' \item{\code{net_home_EPA_pass}}{double.} -#' \item{\code{net_away_EPA_pass}}{double.} -#' \item{\code{success}}{double.} -#' \item{\code{epa_success}}{double.} -#' \item{\code{rz_play}}{double.} -#' \item{\code{scoring_opp}}{double.} -#' \item{\code{middle_8}}{logical.} -#' \item{\code{stuffed_run}}{double.} -#' \item{\code{spread}}{double.} -#' \item{\code{formatted_spread}}{character.} -#' \item{\code{No_Score_before}}{double.} -#' \item{\code{FG_before}}{double.} -#' \item{\code{Opp_FG_before}}{double.} -#' \item{\code{Opp_Safety_before}}{double.} -#' \item{\code{Opp_TD_before}}{double.} -#' \item{\code{Safety_before}}{double.} -#' \item{\code{TD_before}}{double.} -#' \item{\code{No_Score_after}}{double.} -#' \item{\code{FG_after}}{double.} -#' \item{\code{Opp_FG_after}}{double.} -#' \item{\code{Opp_Safety_after}}{double.} -#' \item{\code{Opp_TD_after}}{double.} -#' \item{\code{Safety_after}}{double.} -#' \item{\code{TD_after}}{double.} -#' \item{\code{penalty_flag}}{logical.} -#' \item{\code{penalty_declined}}{logical.} -#' \item{\code{penalty_no_play}}{logical.} -#' \item{\code{penalty_offset}}{logical.} -#' \item{\code{penalty_text}}{logical.} -#' \item{\code{penalty_play_text}}{character.} -#' \item{\code{lead_wp_before2}}{double.} -#' \item{\code{wpa_half_end}}{double.} -#' \item{\code{wpa_base}}{double.} -#' \item{\code{wpa_base_nxt}}{double.} -#' \item{\code{wpa_change}}{double.} -#' \item{\code{wpa_change_nxt}}{double.} -#' \item{\code{wpa_base_ind}}{double.} -#' \item{\code{wpa_base_nxt_ind}}{double.} -#' \item{\code{wpa_change_ind}}{double.} -#' \item{\code{wpa_change_nxt_ind}}{double.} -#' \item{\code{lead_wp_before}}{double.} -#' \item{\code{lead_pos_team2}}{character.} -#' \item{\code{lag_change_of_pos_team2}}{double.} -#' \item{\code{lag_punt2}}{double.} -#' \item{\code{lag_score_diff}}{double.} -#' \item{\code{lag_offense_play}}{character.} -#' \item{\code{lead_offense_play}}{character.} -#' \item{\code{lead_offense_play2}}{character.} -#' \item{\code{lag_pos_score_diff}}{double.} -#' \item{\code{lag_off_timeouts}}{double.} -#' \item{\code{lag_def_timeouts}}{double.} -#' \item{\code{lag_TimeSecsRem2}}{double.} -#' \item{\code{lag_TimeSecsRem}}{double.} -#' \item{\code{lead_TimeSecsRem}}{double.} -#' \item{\code{lead_TimeSecsRem2}}{double.} -#' \item{\code{lag_yards_to_goal2}}{integer.} -#' \item{\code{lag_yards_to_goal}}{integer.} -#' \item{\code{lead_yards_to_goal}}{double.} -#' \item{\code{lead_yards_to_goal2}}{integer.} -#' \item{\code{lag_down2}}{double.} -#' \item{\code{lag_down}}{double.} -#' \item{\code{lead_down}}{double.} -#' \item{\code{lead_down2}}{double.} -#' \item{\code{lead_distance}}{double.} -#' \item{\code{lead_distance2}}{integer.} -#' \item{\code{lead_play_type2}}{character.} -#' \item{\code{lead_play_type3}}{character.} -#' \item{\code{lag_ep_before3}}{double.} -#' \item{\code{lag_ep_before2}}{double.} -#' \item{\code{lag_ep_before}}{double.} -#' \item{\code{lead_ep_before}}{double.} -#' \item{\code{lead_ep_before2}}{double.} -#' \item{\code{lag_ep_after}}{double.} -#' \item{\code{lag_ep_after2}}{double.} -#' \item{\code{lag_ep_after3}}{double.} -#' \item{\code{lead_ep_after}}{double.} -#' \item{\code{lead_ep_after2}}{double.} -#' \item{\code{play_number}}{integer.} -#' \item{\code{over_under}}{double.} -#' \item{\code{event}}{double.} -#' \item{\code{game_event_number}}{double.} -#' \item{\code{game_row_number}}{integer.} -#' \item{\code{half_event}}{double.} -#' \item{\code{half_event_number}}{double.} -#' \item{\code{half_row_number}}{integer.} -#' \item{\code{lag_distance3}}{integer.} -#' \item{\code{lag_distance2}}{integer.} -#' \item{\code{lag_distance}}{integer.} -#' \item{\code{lag_yards_gained3}}{integer.} -#' \item{\code{lag_yards_gained2}}{integer.} -#' \item{\code{lag_yards_gained}}{integer.} -#' \item{\code{lead_yards_gained}}{integer.} -#' \item{\code{lead_yards_gained2}}{integer.} -#' \item{\code{lag_play_text3}}{character.} -#' \item{\code{lead_play_text2}}{character.} -#' \item{\code{lead_play_text3}}{character.} -#' \item{\code{lag_change_of_poss2}}{double.} -#' \item{\code{lag_change_of_poss3}}{double.} -#' \item{\code{lag_change_of_pos_team3}}{double.} -#' \item{\code{lag_kickoff_play2}}{double.} -#' \item{\code{lag_kickoff_play3}}{double.} -#' \item{\code{lag_punt3}}{double.} -#' \item{\code{lag_scoring_play2}}{double.} -#' \item{\code{lag_scoring_play3}}{double.} -#' \item{\code{lag_turnover_vec2}}{double.} -#' \item{\code{lag_turnover_vec3}}{double.} -#' \item{\code{lag_downs_turnover2}}{double.} -#' \item{\code{lag_downs_turnover3}}{double.} -#' \item{\code{drive_event}}{double.} -#' \item{\code{lag_first_by_penalty3}}{double.} -#' \item{\code{lag_first_by_yards3}}{double.} +#' \item{`year`: double.}{.} +#' \item{`week`: double.}{.} +#' \item{`id_play`: character.}{.} +#' \item{`game_id`: integer.}{.} +#' \item{`game_play_number`: double.}{.} +#' \item{`half_play_number`: double.}{.} +#' \item{`pos_team`: character.}{.} +#' \item{`def_pos_team`: character.}{.} +#' \item{`half`: integer.}{.} +#' \item{`period`: integer.}{.} +#' \item{`clock.minutes`: integer.}{.} +#' \item{`clock.seconds`: integer.}{.} +#' \item{`play_type`: character.}{.} +#' \item{`play_text`: character.}{.} +#' \item{`down`: double.}{.} +#' \item{`distance`: double.}{.} +#' \item{`yards_to_goal`: double.}{.} +#' \item{`yards_gained`: double.}{.} +#' \item{`penalty_1st_conv`: logical.}{.} +#' \item{`new_series`: double.}{.} +#' \item{`change_of_pos_team`: double.}{.} +#' \item{`lag_change_of_pos_team`: double.}{.} +#' \item{`orig_play_type`: character.}{.} +#' \item{`lead_play_type`: character.}{.} +#' \item{`lag_play_type`: character.}{.} +#' \item{`lag_play_type2`: character.}{.} +#' \item{`lag_play_type3`: character.}{.} +#' \item{`row`: integer.}{.} +#' \item{`drive_play_number`: double.}{.} +#' \item{`drive_event_number`: double.}{.} +#' \item{`lag_play_text`: character.}{.} +#' \item{`lag_play_text2`: character.}{.} +#' \item{`lead_play_text`: character.}{.} +#' \item{`firstD_by_kickoff`: double.}{.} +#' \item{`firstD_by_poss`: double.}{.} +#' \item{`firstD_by_penalty`: double.}{.} +#' \item{`firstD_by_yards`: double.}{.} +#' \item{`lag_first_by_penalty`: double.}{.} +#' \item{`lag_first_by_penalty2`: double.}{.} +#' \item{`lag_first_by_yards`: double.}{.} +#' \item{`lag_first_by_yards2`: double.}{.} +#' \item{`first_by_penalty`: double.}{.} +#' \item{`first_by_yards`: double.}{.} +#' \item{`play_after_turnover`: double.}{.} +#' \item{`lag_change_of_poss`: double.}{.} +#' \item{`lag_kickoff_play`: double.}{.} +#' \item{`lag_punt`: double.}{.} +#' \item{`lag_scoring_play`: double.}{.} +#' \item{`lag_turnover_vec`: double.}{.} +#' \item{`lag_downs_turnover`: double.}{.} +#' \item{`lag_defense_score_play`: double.}{.} +#' \item{`EPA`: double.}{.} +#' \item{`ep_before`: double.}{.} +#' \item{`ep_after`: double.}{.} +#' \item{`wpa`: double.}{.} +#' \item{`wp_before`: double.}{.} +#' \item{`wp_after`: double.}{.} +#' \item{`def_wp_before`: double.}{.} +#' \item{`def_wp_after`: double.}{.} +#' \item{`penalty_detail`: character.}{.} +#' \item{`yds_penalty`: double.}{.} +#' \item{`downs_turnover`: double.}{.} +#' \item{`turnover`: double.}{.} +#' \item{`pos_score_diff_start`: double.}{.} +#' \item{`pos_score_pts`: double.}{.} +#' \item{`pos_team_score`: integer.}{.} +#' \item{`def_pos_team_score`: integer.}{.} +#' \item{`log_ydstogo`: double.}{.} +#' \item{`ExpScoreDiff`: double.}{.} +#' \item{`ExpScoreDiff_Time_Ratio`: double.}{.} +#' \item{`half_clock.minutes`: double.}{.} +#' \item{`TimeSecsRem`: double.}{.} +#' \item{`adj_TimeSecsRem`: double.}{.} +#' \item{`Goal_To_Go`: logical.}{.} +#' \item{`Under_two`: logical.}{.} +#' \item{`home`: character.}{.} +#' \item{`away`: character.}{.} +#' \item{`home_wp_before`: double.}{.} +#' \item{`away_wp_before`: double.}{.} +#' \item{`home_wp_after`: double.}{.} +#' \item{`away_wp_after`: double.}{.} +#' \item{`end_of_half`: double.}{.} +#' \item{`pos_team_receives_2H_kickoff`: double.}{.} +#' \item{`lead_pos_team`: character.}{.} +#' \item{`lag_pos_team`: character.}{.} +#' \item{`Under_three`: logical.}{.} +#' \item{`down_end`: integer.}{.} +#' \item{`distance_end`: double.}{.} +#' \item{`log_ydstogo_end`: double.}{.} +#' \item{`yards_to_goal_end`: double.}{.} +#' \item{`TimeSecsRem_end`: double.}{.} +#' \item{`Goal_To_Go_end`: logical.}{.} +#' \item{`Under_two_end`: logical.}{.} +#' \item{`def_EPA`: double.}{.} +#' \item{`offense_score_play`: double.}{.} +#' \item{`defense_score_play`: double.}{.} +#' \item{`ppa`: character.}{.} +#' \item{`yard_line`: integer.}{.} +#' \item{`scoring`: logical.}{.} +#' \item{`pos_team_timeouts_rem_before`: double.}{.} +#' \item{`def_pos_team_timeouts_rem_before`: double.}{.} +#' \item{`pos_team_timeouts`: integer.}{.} +#' \item{`def_pos_team_timeouts`: integer.}{.} +#' \item{`pos_score_diff`: integer.}{.} +#' \item{`pos_score_diff_start_end`: double.}{.} +#' \item{`offense_play`: character.}{.} +#' \item{`defense_play`: character.}{.} +#' \item{`offense_receives_2H_kickoff`: double.}{.} +#' \item{`change_of_poss`: double.}{.} +#' \item{`score_pts`: double.}{.} +#' \item{`score_diff_start`: double.}{.} +#' \item{`score_diff`: integer.}{.} +#' \item{`offense_score`: integer.}{.} +#' \item{`defense_score`: integer.}{.} +#' \item{`offense_conference`: character.}{.} +#' \item{`defense_conference`: character.}{.} +#' \item{`off_timeout_called`: double.}{.} +#' \item{`def_timeout_called`: double.}{.} +#' \item{`offense_timeouts`: integer.}{.} +#' \item{`defense_timeouts`: integer.}{.} +#' \item{`off_timeouts_rem_before`: double.}{.} +#' \item{`def_timeouts_rem_before`: double.}{.} +#' \item{`rusher_player_name`: character.}{.} +#' \item{`yds_rushed`: double.}{.} +#' \item{`passer_player_name`: character.}{.} +#' \item{`receiver_player_name`: character.}{.} +#' \item{`yds_receiving`: double.}{.} +#' \item{`yds_sacked`: double.}{.} +#' \item{`sack_players`: character.}{.} +#' \item{`sack_player_name`: character.}{.} +#' \item{`sack_player_name2`: character.}{.} +#' \item{`pass_breakup_player_name`: character.}{.} +#' \item{`interception_player_name`: character.}{.} +#' \item{`yds_int_return`: double.}{.} +#' \item{`fumble_player_name`: character.}{.} +#' \item{`fumble_forced_player_name`: character.}{.} +#' \item{`fumble_recovered_player_name`: character.}{.} +#' \item{`yds_fumble_return`: double.}{.} +#' \item{`punter_player_name`: character.}{.} +#' \item{`yds_punted`: double.}{.} +#' \item{`punt_returner_player_name`: character.}{.} +#' \item{`yds_punt_return`: double.}{.} +#' \item{`yds_punt_gained`: double.}{.} +#' \item{`punt_block_player_name`: character.}{.} +#' \item{`punt_block_return_player_name`: character.}{.} +#' \item{`fg_kicker_player_name`: character.}{.} +#' \item{`yds_fg`: double.}{.} +#' \item{`fg_block_player_name`: character.}{.} +#' \item{`fg_return_player_name`: character.}{.} +#' \item{`kickoff_player_name`: character.}{.} +#' \item{`yds_kickoff`: double.}{.} +#' \item{`kickoff_returner_player_name`: character.}{.} +#' \item{`yds_kickoff_return`: double.}{.} +#' \item{`new_id`: double.}{.} +#' \item{`orig_drive_number`: integer.}{.} +#' \item{`drive_number`: integer.}{.} +#' \item{`drive_result_detailed`: character.}{.} +#' \item{`new_drive_pts`: double.}{.} +#' \item{`drive_id`: double.}{.} +#' \item{`drive_result`: character.}{.} +#' \item{`drive_start_yards_to_goal`: double.}{.} +#' \item{`drive_end_yards_to_goal`: integer.}{.} +#' \item{`drive_yards`: integer.}{.} +#' \item{`drive_scoring`: double.}{.} +#' \item{`drive_pts`: double.}{.} +#' \item{`drive_start_period`: integer.}{.} +#' \item{`drive_end_period`: integer.}{.} +#' \item{`drive_time_minutes_start`: integer.}{.} +#' \item{`drive_time_seconds_start`: integer.}{.} +#' \item{`drive_time_minutes_end`: integer.}{.} +#' \item{`drive_time_seconds_end`: integer.}{.} +#' \item{`drive_time_minutes_elapsed`: integer.}{.} +#' \item{`drive_time_seconds_elapsed`: integer.}{.} +#' \item{`drive_numbers`: double.}{.} +#' \item{`number_of_drives`: double.}{.} +#' \item{`pts_scored`: double.}{.} +#' \item{`drive_result_detailed_flag`: character.}{.} +#' \item{`drive_result2`: character.}{.} +#' \item{`drive_num`: double.}{.} +#' \item{`lag_drive_result_detailed`: character.}{.} +#' \item{`lead_drive_result_detailed`: character.}{.} +#' \item{`lag_new_drive_pts`: double.}{.} +#' \item{`id_drive`: character.}{.} +#' \item{`rush`: double.}{.} +#' \item{`rush_td`: double.}{.} +#' \item{`pass`: double.}{.} +#' \item{`pass_td`: double.}{.} +#' \item{`completion`: double.}{.} +#' \item{`pass_attempt`: double.}{.} +#' \item{`target`: double.}{.} +#' \item{`sack_vec`: double.}{.} +#' \item{`sack`: double.}{.} +#' \item{`int`: double.}{.} +#' \item{`int_td`: double.}{.} +#' \item{`turnover_vec`: double.}{.} +#' \item{`turnover_vec_lag`: double.}{.} +#' \item{`turnover_indicator`: double.}{.} +#' \item{`kickoff_play`: double.}{.} +#' \item{`receives_2H_kickoff`: double.}{.} +#' \item{`missing_yard_flag`: logical.}{.} +#' \item{`scoring_play`: double.}{.} +#' \item{`td_play`: double.}{.} +#' \item{`touchdown`: double.}{.} +#' \item{`safety`: double.}{.} +#' \item{`fumble_vec`: double.}{.} +#' \item{`kickoff_tb`: double.}{.} +#' \item{`kickoff_onside`: double.}{.} +#' \item{`kickoff_oob`: double.}{.} +#' \item{`kickoff_fair_catch`: double.}{.} +#' \item{`kickoff_downed`: double.}{.} +#' \item{`kickoff_safety`: double.}{.} +#' \item{`kick_play`: double.}{.} +#' \item{`punt`: double.}{.} +#' \item{`punt_play`: double.}{.} +#' \item{`punt_tb`: double.}{.} +#' \item{`punt_oob`: double.}{.} +#' \item{`punt_fair_catch`: double.}{.} +#' \item{`punt_downed`: double.}{.} +#' \item{`punt_safety`: double.}{.} +#' \item{`punt_blocked`: double.}{.} +#' \item{`penalty_safety`: double.}{.} +#' \item{`fg_inds`: double.}{.} +#' \item{`fg_made`: logical.}{.} +#' \item{`fg_make_prob`: double.}{.} +#' \item{`home_EPA`: double.}{.} +#' \item{`away_EPA`: double.}{.} +#' \item{`home_EPA_rush`: double.}{.} +#' \item{`away_EPA_rush`: double.}{.} +#' \item{`home_EPA_pass`: double.}{.} +#' \item{`away_EPA_pass`: double.}{.} +#' \item{`total_home_EPA`: double.}{.} +#' \item{`total_away_EPA`: double.}{.} +#' \item{`total_home_EPA_rush`: double.}{.} +#' \item{`total_away_EPA_rush`: double.}{.} +#' \item{`total_home_EPA_pass`: double.}{.} +#' \item{`total_away_EPA_pass`: double.}{.} +#' \item{`net_home_EPA`: double.}{.} +#' \item{`net_away_EPA`: double.}{.} +#' \item{`net_home_EPA_rush`: double.}{.} +#' \item{`net_away_EPA_rush`: double.}{.} +#' \item{`net_home_EPA_pass`: double.}{.} +#' \item{`net_away_EPA_pass`: double.}{.} +#' \item{`success`: double.}{.} +#' \item{`epa_success`: double.}{.} +#' \item{`rz_play`: double.}{.} +#' \item{`scoring_opp`: double.}{.} +#' \item{`middle_8`: logical.}{.} +#' \item{`stuffed_run`: double.}{.} +#' \item{`spread`: double.}{.} +#' \item{`formatted_spread`: character.}{.} +#' \item{`No_Score_before`: double.}{.} +#' \item{`FG_before`: double.}{.} +#' \item{`Opp_FG_before`: double.}{.} +#' \item{`Opp_Safety_before`: double.}{.} +#' \item{`Opp_TD_before`: double.}{.} +#' \item{`Safety_before`: double.}{.} +#' \item{`TD_before`: double.}{.} +#' \item{`No_Score_after`: double.}{.} +#' \item{`FG_after`: double.}{.} +#' \item{`Opp_FG_after`: double.}{.} +#' \item{`Opp_Safety_after`: double.}{.} +#' \item{`Opp_TD_after`: double.}{.} +#' \item{`Safety_after`: double.}{.} +#' \item{`TD_after`: double.}{.} +#' \item{`penalty_flag`: logical.}{.} +#' \item{`penalty_declined`: logical.}{.} +#' \item{`penalty_no_play`: logical.}{.} +#' \item{`penalty_offset`: logical.}{.} +#' \item{`penalty_text`: logical.}{.} +#' \item{`penalty_play_text`: character.}{.} +#' \item{`lead_wp_before2`: double.}{.} +#' \item{`wpa_half_end`: double.}{.} +#' \item{`wpa_base`: double.}{.} +#' \item{`wpa_base_nxt`: double.}{.} +#' \item{`wpa_change`: double.}{.} +#' \item{`wpa_change_nxt`: double.}{.} +#' \item{`wpa_base_ind`: double.}{.} +#' \item{`wpa_base_nxt_ind`: double.}{.} +#' \item{`wpa_change_ind`: double.}{.} +#' \item{`wpa_change_nxt_ind`: double.}{.} +#' \item{`lead_wp_before`: double.}{.} +#' \item{`lead_pos_team2`: character.}{.} +#' \item{`lag_change_of_pos_team2`: double.}{.} +#' \item{`lag_punt2`: double.}{.} +#' \item{`lag_score_diff`: double.}{.} +#' \item{`lag_offense_play`: character.}{.} +#' \item{`lead_offense_play`: character.}{.} +#' \item{`lead_offense_play2`: character.}{.} +#' \item{`lag_pos_score_diff`: double.}{.} +#' \item{`lag_off_timeouts`: double.}{.} +#' \item{`lag_def_timeouts`: double.}{.} +#' \item{`lag_TimeSecsRem2`: double.}{.} +#' \item{`lag_TimeSecsRem`: double.}{.} +#' \item{`lead_TimeSecsRem`: double.}{.} +#' \item{`lead_TimeSecsRem2`: double.}{.} +#' \item{`lag_yards_to_goal2`: integer.}{.} +#' \item{`lag_yards_to_goal`: integer.}{.} +#' \item{`lead_yards_to_goal`: double.}{.} +#' \item{`lead_yards_to_goal2`: integer.}{.} +#' \item{`lag_down2`: double.}{.} +#' \item{`lag_down`: double.}{.} +#' \item{`lead_down`: double.}{.} +#' \item{`lead_down2`: double.}{.} +#' \item{`lead_distance`: double.}{.} +#' \item{`lead_distance2`: integer.}{.} +#' \item{`lead_play_type2`: character.}{.} +#' \item{`lead_play_type3`: character.}{.} +#' \item{`lag_ep_before3`: double.}{.} +#' \item{`lag_ep_before2`: double.}{.} +#' \item{`lag_ep_before`: double.}{.} +#' \item{`lead_ep_before`: double.}{.} +#' \item{`lead_ep_before2`: double.}{.} +#' \item{`lag_ep_after`: double.}{.} +#' \item{`lag_ep_after2`: double.}{.} +#' \item{`lag_ep_after3`: double.}{.} +#' \item{`lead_ep_after`: double.}{.} +#' \item{`lead_ep_after2`: double.}{.} +#' \item{`play_number`: integer.}{.} +#' \item{`over_under`: double.}{.} +#' \item{`event`: double.}{.} +#' \item{`game_event_number`: double.}{.} +#' \item{`game_row_number`: integer.}{.} +#' \item{`half_event`: double.}{.} +#' \item{`half_event_number`: double.}{.} +#' \item{`half_row_number`: integer.}{.} +#' \item{`lag_distance3`: integer.}{.} +#' \item{`lag_distance2`: integer.}{.} +#' \item{`lag_distance`: integer.}{.} +#' \item{`lag_yards_gained3`: integer.}{.} +#' \item{`lag_yards_gained2`: integer.}{.} +#' \item{`lag_yards_gained`: integer.}{.} +#' \item{`lead_yards_gained`: integer.}{.} +#' \item{`lead_yards_gained2`: integer.}{.} +#' \item{`lag_play_text3`: character.}{.} +#' \item{`lead_play_text2`: character.}{.} +#' \item{`lead_play_text3`: character.}{.} +#' \item{`lag_change_of_poss2`: double.}{.} +#' \item{`lag_change_of_poss3`: double.}{.} +#' \item{`lag_change_of_pos_team3`: double.}{.} +#' \item{`lag_kickoff_play2`: double.}{.} +#' \item{`lag_kickoff_play3`: double.}{.} +#' \item{`lag_punt3`: double.}{.} +#' \item{`lag_scoring_play2`: double.}{.} +#' \item{`lag_scoring_play3`: double.}{.} +#' \item{`lag_turnover_vec2`: double.}{.} +#' \item{`lag_turnover_vec3`: double.}{.} +#' \item{`lag_downs_turnover2`: double.}{.} +#' \item{`lag_downs_turnover3`: double.}{.} +#' \item{`drive_event`: double.}{.} +#' \item{`lag_first_by_penalty3`: double.}{.} +#' \item{`lag_first_by_yards3`: double.}{.} #' } #' @keywords Play-by-Play #' @import stringr @@ -765,85 +763,98 @@ cfbd_pbp_data <- function(year, -#' Adds play counts to Play-by-Play data -#' Adds play counts to Play-by-Play data pulled from the API's raw game data +#' @name helpers_pbp +#' @aliases add_play_counts clean_drive_dat prep_epa_df_after clean_drive_info +#' add_player_cols add_yardage clean_pbp_dat penalty_detection +#' @title Series of functions to help clean the play-by-play data for analysis +#' @description +#' \describe{ +#' \item{`add_play_counts()`: function}{Adds play counts to Play-by-Play data pulled from the API's raw game data.} +#' \item{`add_yardage()`: Add yardage extracted from play text}{.} +#' \item{`add_player_cols()`: function}{Add player columns extracted from play text.} +#' \item{`clean_drive_dat()`: function}{Create new Drive results and id data.} +#' \item{`clean_pbp_dat()`: function}{Clean Play-by-Play data.} +#' \item{`penalty_detection()`: function}{Adds penalty columns to Play-by-Play data pulled from the API.} +#' \item{`prep_epa_df_after()`: function}{Creates the post-play inputs for the Expected Points model to predict on for each game.} +#' \item{`clean_drive_info()`: function}{Cleans CFB (D-I) Drive-By-Drive Data to create `pts_drive` column.} +#' } #' @param play_df (\emph{data.frame} required): Adds play counts to Play-by-Play dataframe, as pulled from `cfbd_pbp_data()` #' @details Requires the following columns to be present #' \describe{ -#' \item{game_id}{.} -#' \item{id_play}{.} -#' \item{clock.minutes}{.} -#' \item{clock.seconds}{.} -#' \item{half}{.} -#' \item{period}{.} -#' \item{offense_play}{.} -#' \item{defense_play}{.} -#' \item{home}{.} -#' \item{away}{.} -#' \item{offense_score}{.} -#' \item{defense_score}{.} -#' \item{offense_timeouts}{.} -#' \item{offense_timeouts}{.} -#' \item{play_text}{.} -#' \item{play_type}{.} +#' \item{`game_id`}{.} +#' \item{`id_play`}{.} +#' \item{`clock.minutes`}{.} +#' \item{`clock.seconds`}{.} +#' \item{`half`}{.} +#' \item{`period`}{.} +#' \item{`offense_play`}{.} +#' \item{`defense_play`}{.} +#' \item{`home`}{.} +#' \item{`away`}{.} +#' \item{`offense_score`}{.} +#' \item{`defense_score`}{.} +#' \item{`offense_timeouts`}{.} +#' \item{`offense_timeouts`}{.} +#' \item{`play_text`}{.} +#' \item{`play_type`}{.} #' } #' @return The original `play_df` with the following columns appended/redefined: #' \describe{ -#' \item{game_play_number}{.} -#' \item{half_clock.minutes}{.} -#' \item{TimeSecsRem}{.} -#' \item{Under_two}{.} -#' \item{half}{.} -#' \item{kickoff_play}{.} -#' \item{pos_team}{.} -#' \item{def_pos_team}{.} -#' \item{receives_2H_kickoff}{.} -#' \item{pos_score_diff}{.} -#' \item{lag_pos_score_diff}{.} -#' \item{lag_pos_team}{.} -#' \item{lead_pos_team}{.} -#' \item{lead_pos_team2}{.} -#' \item{pos_score_pts}{.} -#' \item{pos_score_diff_start}{.} -#' \item{score_diff}{.} -#' \item{lag_score_diff}{.} -#' \item{lag_offense_play}{.} -#' \item{lead_offense_play}{.} -#' \item{lead_offense_play2}{.} -#' \item{score_pts}{.} -#' \item{score_diff_start}{.} -#' \item{offense_receives_2H_kickoff}{.} -#' \item{half_play_number}{.} -#' \item{lag_off_timeouts}{.} -#' \item{lag_def_timeouts}{.} -#' \item{off_timeouts_rem_before}{.} -#' \item{def_timeouts_rem_before}{.} -#' \item{off_timeout_called}{.} -#' \item{def_timeout_called}{.} -#' \item{lead_TimeSecsRem}{.} -#' \item{lead_TimeSecsRem2}{.} -#' \item{lead_yards_to_goal}{.} -#' \item{lead_yards_to_goal2}{.} -#' \item{lead_down}{.} -#' \item{lead_down2}{.} -#' \item{lag_distance3}{.} -#' \item{lag_distance2}{.} -#' \item{lag_distance}{.} -#' \item{lead_distance}{.} -#' \item{lead_distance2}{.} -#' \item{end_of_half}{.} -#' \item{lag_play_type3}{.} -#' \item{lag_play_type2}{.} -#' \item{lag_play_type}{.} -#' \item{lead_play_type}{.} -#' \item{lead_play_type2}{.} -#' \item{lead_play_type3}{.} -#' \item{change_of_poss}{.} -#' \item{change_of_pos_team}{.} -#' \item{pos_team_timeouts}{.} -#' \item{def_pos_team_timeouts}{.} -#' \item{pos_team_timeouts_rem_before}{.} -#' \item{def_pos_team_timeouts_rem_before}{.} +#' \item{`game_play_number`.}{.} +#' \item{`half_clock.minutes`.}{.} +#' \item{`TimeSecsRem`.}{.} +#' \item{`Under_two`.}{.} +#' \item{`half`.}{.} +#' \item{`kickoff_play`.}{.} +#' \item{`pos_team`.}{.} +#' \item{`def_pos_team`.}{.} +#' \item{`receives_2H_kickoff`.}{.} +#' \item{`pos_score_diff`.}{.} +#' \item{`lag_pos_score_diff`.}{.} +#' \item{`lag_pos_team`.}{.} +#' \item{`lead_pos_team`.}{.} +#' \item{`lead_pos_team2`.}{.} +#' \item{`pos_score_pts`.}{.} +#' \item{`pos_score_diff_start`.}{.} +#' \item{`score_diff`.}{.} +#' \item{`lag_score_diff`.}{.} +#' \item{`lag_offense_play`.}{.} +#' \item{`lead_offense_play`.}{.} +#' \item{`lead_offense_play2`.}{.} +#' \item{`score_pts`.}{.} +#' \item{`score_diff_start`.}{.} +#' \item{`offense_receives_2H_kickoff`.}{.} +#' \item{`half_play_number`.}{.} +#' \item{`lag_off_timeouts`.}{.} +#' \item{`lag_def_timeouts`.}{.} +#' \item{`off_timeouts_rem_before`.}{.} +#' \item{`def_timeouts_rem_before`.}{.} +#' \item{`off_timeout_called`.}{.} +#' \item{`def_timeout_called`.}{.} +#' \item{`lead_TimeSecsRem`.}{.} +#' \item{`lead_TimeSecsRem2`.}{.} +#' \item{`lead_yards_to_goal`.}{.} +#' \item{`lead_yards_to_goal2`.}{.} +#' \item{`lead_down`.}{.} +#' \item{`lead_down2`.}{.} +#' \item{`lag_distance3`.}{.} +#' \item{`lag_distance2`.}{.} +#' \item{`lag_distance`.}{.} +#' \item{`lead_distance`.}{.} +#' \item{`lead_distance2`.}{.} +#' \item{`end_of_half`.}{.} +#' \item{`lag_play_type3`.}{.} +#' \item{`lag_play_type2`.}{.} +#' \item{`lag_play_type`.}{.} +#' \item{`lead_play_type`.}{.} +#' \item{`lead_play_type2`.}{.} +#' \item{`lead_play_type3`.}{.} +#' \item{`change_of_poss`.}{.} +#' \item{`change_of_pos_team`.}{.} +#' \item{`pos_team_timeouts`.}{.} +#' \item{`def_pos_team_timeouts`.}{.} +#' \item{`pos_team_timeouts_rem_before`.}{.} +#' \item{`def_pos_team_timeouts_rem_before`.}{.} #' } #' @keywords internal #' @importFrom rlang .data @@ -1155,42 +1166,43 @@ add_play_counts <- function(play_df) { } -#' Create new Drive results and id data -#' Cleans Play-by-Play data pulled from the API's raw game data +#' @rdname helpers_pbp +#' @title Create new Drive results and id data +#' @description Cleans Play-by-Play data pulled from the API's raw game data #' #' @param play_df (\emph{data.frame} required): Performs data cleansing on Play-by-Play DataFrame, as pulled from `cfbd_pbp_data()` #' @return The original `play_df` with the following columns appended/redefined: #' \describe{ -#' \item{lag_change_of_poss}{.} -#' \item{lag_punt}{.} -#' \item{lag_scoring_play}{.} -#' \item{lag_turnover_vec}{.} -#' \item{lag_downs_turnover}{.} -#' \item{lead_play_type}{.} -#' \item{lead_play_type2}{.} -#' \item{lead_play_type3}{.} -#' \item{drive_numbers}{.} -#' \item{number_of_drives}{.} -#' \item{pts_scored}{.} -#' \item{drive_result_detailed}{.} -#' \item{drive_result_detailed_flag}{.} -#' \item{drive_result2}{.} -#' \item{lag_new_drive_pts}{.} -#' \item{lag_drive_result_detailed}{.} -#' \item{lead_drive_result_detailed}{.} -#' \item{new_drive_pts}{.} -#' \item{drive_scoring}{.} -#' \item{drive_play}{.} -#' \item{drive_play_number}{.} -#' \item{drive_event}{.} -#' \item{drive_event_number}{.} -#' \item{new_id}{.} -#' \item{log_ydstogo}{.} -#' \item{down}{.} -#' \item{distance}{.} -#' \item{yards_to_goal}{.} -#' \item{yards_gained}{.} -#' \item{Goal_To_Go}{.} +#' \item{`lag_change_of_poss`.}{.} +#' \item{`lag_punt`.}{.} +#' \item{`lag_scoring_play`.}{.} +#' \item{`lag_turnover_vec`.}{.} +#' \item{`lag_downs_turnover`.}{.} +#' \item{`lead_play_type`.}{.} +#' \item{`lead_play_type2`.}{.} +#' \item{`lead_play_type3`.}{.} +#' \item{`drive_numbers`.}{.} +#' \item{`number_of_drives`.}{.} +#' \item{`pts_scored`.}{.} +#' \item{`drive_result_detailed`.}{.} +#' \item{`drive_result_detailed_flag`.}{.} +#' \item{`drive_result2`.}{.} +#' \item{`lag_new_drive_pts`.}{.} +#' \item{`lag_drive_result_detailed`.}{.} +#' \item{`lead_drive_result_detailed`.}{.} +#' \item{`new_drive_pts`.}{.} +#' \item{`drive_scoring`.}{.} +#' \item{`drive_play`.}{.} +#' \item{`drive_play_number`.}{.} +#' \item{`drive_event`.}{.} +#' \item{`drive_event_number`.}{.} +#' \item{`new_id`.}{.} +#' \item{`log_ydstogo`.}{.} +#' \item{`down`.}{.} +#' \item{`distance`.}{.} +#' \item{`yards_to_goal`.}{.} +#' \item{`yards_gained`.}{.} +#' \item{`Goal_To_Go`.}{.} #' } #' @keywords internal #' @importFrom rlang .data @@ -1519,53 +1531,53 @@ clean_drive_dat <- function(play_df) { return(play_df) } -#' Creates the post-play inputs for the Expected Points model to predict on for each game +#' @rdname helpers_pbp #' #' @param dat (\emph{Data.Frame} required) Clean Play-by-Play DataFrame pulled from `cfbd_pbp_dat()` #' @details Prep for EPA calculations at the end of the play. Requires the following columns be present: #' \itemize{ -#' \item{game_id} -#' \item{id_play} -#' \item{drive_id} -#' \item{down} -#' \item{distance} -#' \item{period} -#' \item{yards_to_goal} -#' \item{play_type} +#' \item{`game_id`.}{.} +#' \item{`id_play`.}{.} +#' \item{`drive_id`.}{.} +#' \item{`down`.}{.} +#' \item{`distance`.}{.} +#' \item{`period`.}{.} +#' \item{`yards_to_goal`.}{.} +#' \item{`play_type`.}{.} #' } #' @return `dat` with the following columns appended/modified: #' \itemize{ -#' \item{turnover_indicator}{.} -#' \item{down}{.} -#' \item{new_id}{.} -#' \item{new_down}{.} -#' \item{distance}{.} -#' \item{yards_to_goal}{.} -#' \item{yards_gained}{.} -#' \item{turnover}{.} -#' \item{drive_start_yards_to_goal}{.} -#' \item{end_of_half}{.} -#' \item{new_yardline}{.} -#' \item{new_distance}{.} -#' \item{new_log_ydstogo}{.} -#' \item{new_Goal_To_Go}{.} -#' \item{new_TimeSecsRem}{.} -#' \item{new_Under_two}{.} -#' \item{first_by_penalty}{.} -#' \item{lag_first_by_penalty}{.} -#' \item{lag_first_by_penalty2}{.} -#' \item{first_by_yards}{.} -#' \item{lag_first_by_yards}{.} -#' \item{lag_first_by_yards2}{.} -#' \item{row}{.} -#' \item{new_series}{.} -#' \item{firstD_by_kickoff}{.} -#' \item{firstD_by_poss}{.} -#' \item{firstD_by_yards}{.} -#' \item{firstD_by_penalty}{.} -#' \item{yds_punted}{.} -#' \item{yds_punt_gained}{.} -#' \item{missing_yard_flag}{.} +#' \item{`turnover_indicator`.}{.} +#' \item{`down`.}{.} +#' \item{`new_id`.}{.} +#' \item{`new_down`.}{.} +#' \item{`distance`.}{.} +#' \item{`yards_to_goal`.}{.} +#' \item{`yards_gained`.}{.} +#' \item{`turnover`.}{.} +#' \item{`drive_start_yards_to_goal`.}{.} +#' \item{`end_of_half`.}{.} +#' \item{`new_yardline`.}{.} +#' \item{`new_distance`.}{.} +#' \item{`new_log_ydstogo`.}{.} +#' \item{`new_Goal_To_Go`.}{.} +#' \item{`new_TimeSecsRem`.}{.} +#' \item{`new_Under_two`.}{.} +#' \item{`first_by_penalty`.}{.} +#' \item{`lag_first_by_penalty`.}{.} +#' \item{`lag_first_by_penalty2`.}{.} +#' \item{`first_by_yards`.}{.} +#' \item{`lag_first_by_yards`.}{.} +#' \item{`lag_first_by_yards2`.}{.} +#' \item{`row`.}{.} +#' \item{`new_series`.}{.} +#' \item{`firstD_by_kickoff`.}{.} +#' \item{`firstD_by_poss`.}{.} +#' \item{`firstD_by_yards`.}{.} +#' \item{`firstD_by_penalty`.}{.} +#' \item{`yds_punted`.}{.} +#' \item{`yds_punt_gained`.}{.} +#' \item{`missing_yard_flag`.}{.} #' } #' @keywords internal #' @importFrom rlang .data @@ -2011,22 +2023,21 @@ prep_epa_df_after <- function(dat) { } -#' Clean Drive Information -#' Cleans CFB (D-I) Drive-By-Drive Data to create `pts_drive` column +#' @rdname helpers_pbp #' #' @param drive_df (\emph{data.frame} required) Drive dataframe pulled from API via the `cfbd_drives()` function #' @details Cleans CFB (D-I) Drive-By-Drive Data to create `pts_drive` column. Requires the following columns be present: #' \itemize{ -#' \item{drive_id}{Returned as `drive_id`} -#' \item{drive_result}{End result of the drive} -#' \item{scoring}{Logical flag for if drive was a scoring drive} -#' \item{game_id}{Unique game identifier} +#' \item{`drive_id`: Returned as `drive_id`}{.} +#' \item{`drive_result`: End result of the drive}{.} +#' \item{`scoring`: Logical flag for if drive was a scoring drive}{.} +#' \item{`game_id`: Unique game identifier}{.} #' } #' @return The original `drive_df` with the following columns appended to it: #' \describe{ -#' \item{drive_id}{Returned as `drive_id` from original variable `drive_id`} -#' \item{pts_drive}{End result of the drive} -#' \item{scoring}{Logical flag for if drive was a scoring drive updated} +#' \item{`drive_id`: Returned as `drive_id` from original variable `drive_id`}{.} +#' \item{`pts_drive`: End result of the drive}{.} +#' \item{`scoring`: Logical flag for if drive was a scoring drive updated}{.} #' } #' @keywords internal #' @importFrom rlang .data diff --git a/R/cfbd_play.R b/R/cfbd_play.R index bb42a899..0fde1def 100644 --- a/R/cfbd_play.R +++ b/R/cfbd_play.R @@ -1,10 +1,14 @@ -#' CFBD Plays Endpoint #' @name cfbd_play -NULL -#' College Football Plays -#' @rdname cfbd_play +#' @aliases cfbd_plays cfbd_play_stats_player cfbd_play_stats_types cfbd_play_types +#' @title CFBD Plays Endpoint +#' @description College football plays data +#' \describe{ +#' \item{`cfbd_plays()`:}{CFBD's College Football Play-by-Play} +#' \item{`cfbd_play_stats_player()`:}{Gets player info associated by play.} +#' \item{`cfbd_play_stats_types()`:}{Gets CFBD play stat types.} +#' \item{`cfbd_play_types()`:}{Gets CFBD play types} +#' } #' @source \url{https://api.collegefootballdata.com/plays} -#' #' @param season_type Select Season Type (regular, postseason, both) #' @param year Select year, (example: 2018) #' @param week Select week, this is optional (also numeric) @@ -17,22 +21,49 @@ NULL #' PAC, MAC, MWC, CUSA, Ind, SBC, AAC, Western, MVIAA, SWC, PCC, Big 6, etc.) #' @param defense_conference Select conference name (example: ACC, B1G, B12, SEC,\cr #' PAC, MAC, MWC, CUSA, Ind, SBC, AAC, Western, MVIAA, SWC, PCC, Big 6, etc.) -#' @param play_type Select play type (example: see the \code{\link[cfbfastR:cfbd_play_type_df]{cfbd_play_type_df}}) +#' @param play_type Select play type (example: see the [cfbd_play_type_df]) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' @return \code{\link[cfbfastR:cfbd_plays]{cfbfastR::cfbd_plays()}} +#' @return [cfbd_plays()] - A data frame with 29 columns: +#' \describe{ +#' \item{`play_id`: character.}{Referencing play id.} +#' \item{`offense`: character.}{Offense on the field.} +#' \item{`offense_conference`: character.}{Conference of the offense on the field.} +#' \item{`defense`: character.}{Defense on the field.} +#' \item{`defense_conference`: character.}{Conference of the defense on the field.} +#' \item{`home`: character.}{Home team.} +#' \item{`away`: character.}{Away team.} +#' \item{`offense_score`: integer.}{Offense's post-play score.} +#' \item{`defense_score`: integer.}{Defense's post-play score.} +#' \item{`game_id`: integer.}{Referencing game id.} +#' \item{`drive_id`: character.}{Referencing drive id.} +#' \item{`drive_number`: integer.}{Drive number in the game.} +#' \item{`play_number`: integer.}{Play number in the game.} +#' \item{`period`: integer.}{Game period (quarter).} +#' \item{`offense_timeouts`: integer.}{Timeouts for the offense at the end of the play.} +#' \item{`defense_timeouts`: integer.}{Timeouts for the defense at the end of the play.} +#' \item{`yard_line`: integer.}{Yard line (~0-50) of the play.} +#' \item{`yards_to_goal`: integer.}{Yards to the goal line (~0-100).} +#' \item{`down`: integer.}{Down of the play.} +#' \item{`distance`: integer.}{Distance to the sticks, i.e. 1st down or goal-line in goal-to-go situations.} +#' \item{`scoring`: logical.}{Scoring play flag.} +#' \item{`yards_gained`: integer.}{Yards net gained by the offense on the play.} +#' \item{`play_type`: character.}{Categorical label of the type of the play.} +#' \item{`play_text`: character.}{A text description of the play.} +#' \item{`ppa`: character.}{Predicted Points Added (calculated by CFBD).} +#' \item{`clock.minutes`: integer.}{Minutes left on the clock.} +#' \item{`clock.seconds`: integer.}{Seconds left on the clock.} +#' } #' @source \url{https://api.collegefootballdata.com/plays} #' @importFrom jsonlite fromJSON #' @importFrom httr GET #' @importFrom utils URLencode #' @importFrom assertthat assert_that #' @importFrom glue glue -#' - - +#' @export cfbd_plays <- function(year = 2020, season_type = "regular", - week = 4, - team = "Florida State", + week = 1, + team = NULL, offense = NULL, defense = NULL, conference = NULL, @@ -141,76 +172,75 @@ cfbd_plays <- function(year = 2020, return(df) } -#' Gets player info associated by play #' @rdname cfbd_play +#' @title Gets player info associated by play #' @param year (\emph{Integer} optional): Year, 4 digit format (\emph{YYYY}) #' @param week (\emph{Integer} optional): Week - values from 1-15, 1-14 for seasons pre-playoff, i.e. 2013 or earlier #' @param team (\emph{String} optional): D-I Team -#' @param game_id (\emph{Integer} optional): Game ID filter for querying a single game\cr -#' Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function -#' @param athlete_id (\emph{Integer} optional): Athlete ID filter for querying a single athlete\cr -#' Can be found using the \code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_player_info()}} function. -#' @param stat_type_id (\emph{Integer} optional): Stat Type ID filter for querying a single stat type\cr -#' Can be found using the \code{\link[cfbfastR:cfbd_play_stats_types]{cfbfastR::cfbd_play_stats_types()}} function +#' @param game_id (\emph{Integer} optional): Game ID filter for querying a single game +#' Can be found using the [cfbd_game_info()] function +#' @param athlete_id (\emph{Integer} optional): Athlete ID filter for querying a single athlete +#' Can be found using the [cfbd_player_info()] function. +#' @param stat_type_id (\emph{Integer} optional): Stat Type ID filter for querying a single stat type +#' Can be found using the [cfbd_play_stats_types()] function #' @param season_type (\emph{String} default regular): Select Season Type: regular, postseason, or both #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' -#' @return \code{\link[cfbfastR:cfbd_play_stats_player]{cfbfastR::cfbd_play_stats_player()}} - A data frame with 54 variables: +#' @return [cfbd_play_stats_player()] - A data frame with 54 variables: #' \describe{ -#' \item{\code{play_id}}{character.} -#' \item{\code{game_id}}{integer.} -#' \item{\code{season}}{integer.} -#' \item{\code{week}}{integer.} -#' \item{\code{opponent}}{character.} -#' \item{\code{team_score}}{integer.} -#' \item{\code{opponent_score}}{integer.} -#' \item{\code{drive_id}}{character.} -#' \item{\code{period}}{integer.} -#' \item{\code{yards_to_goal}}{integer.} -#' \item{\code{down}}{integer.} -#' \item{\code{distance}}{integer.} -#' \item{\code{reception_player_id}}{character.} -#' \item{\code{reception_player}}{character.} -#' \item{\code{reception_yds}}{integer.} -#' \item{\code{completion_player_id}}{character.} -#' \item{\code{completion_player}}{character.} -#' \item{\code{completion_yds}}{integer.} -#' \item{\code{rush_player_id}}{character.} -#' \item{\code{rush_player}}{character.} -#' \item{\code{rush_yds}}{integer.} -#' \item{\code{interception_player_id}}{character.} -#' \item{\code{interception_player}}{character.} -#' \item{\code{interception_stat}}{integer.} -#' \item{\code{interception_thrown_player_id}}{character.} -#' \item{\code{interception_thrown_player}}{character.} -#' \item{\code{interception_thrown_stat}}{integer.} -#' \item{\code{touchdown_player_id}}{character.} -#' \item{\code{touchdown_player}}{character.} -#' \item{\code{touchdown_stat}}{integer.} -#' \item{\code{incompletion_player_id}}{character.} -#' \item{\code{incompletion_player}}{character.} -#' \item{\code{incompletion_stat}}{integer.} -#' \item{\code{target_player_id}}{character.} -#' \item{\code{target_player}}{character.} -#' \item{\code{target_stat}}{integer.} -#' \item{\code{fumble_recovered_player_id}}{logical.} -#' \item{\code{fumble_recovered_player}}{logical.} -#' \item{\code{fumble_recovered_stat}}{logical.} -#' \item{\code{fumble_forced_player_id}}{logical.} -#' \item{\code{fumble_forced_player}}{logical.} -#' \item{\code{fumble_forced_stat}}{logical.} -#' \item{\code{fumble_player_id}}{logical.} -#' \item{\code{fumble_player}}{logical.} -#' \item{\code{fumble_stat}}{logical.} -#' \item{\code{sack_player_id}}{character.} -#' \item{\code{sack_player}}{character.} -#' \item{\code{sack_stat}}{integer.} -#' \item{\code{sack_taken_player_id}}{character.} -#' \item{\code{sack_taken_player}}{character.} -#' \item{\code{sack_taken_stat}}{integer.} -#' \item{\code{pass_breakup_player_id}}{logical.} -#' \item{\code{pass_breakup_player}}{logical.} -#' \item{\code{pass_breakup_stat}}{logical.} +#' \item{`play_id`: character.}{Referencing play id.} +#' \item{`game_id`: integer.}{Referencing game id.} +#' \item{`season`: integer.}{Season of the play.} +#' \item{`week`: integer.}{Week of the play.} +#' \item{`opponent`: character.}{Opponent of the offense on the play.} +#' \item{`team_score`: integer.}{Offense team score.} +#' \item{`opponent_score`: integer.}{Defense team score.} +#' \item{`drive_id`: character.}{Referencing drive id.} +#' \item{`period`: integer.}{Game period (quarter) of the play.} +#' \item{`yards_to_goal`: integer.}{Yards to the goal line (~0-100).} +#' \item{`down`: integer.}{Down of the play.} +#' \item{`distance`: integer.}{Distance to the sticks, i.e. 1st down or goal-line in goal-to-go situations.} +#' \item{`reception_player_id`: character.}{Pass receiver player reference id.} +#' \item{`reception_player`: character.}{Pass receiver player name.} +#' \item{`reception_yds`: integer.}{Reception yards.} +#' \item{`completion_player_id`: character.}{Passing player reference id.} +#' \item{`completion_player`: character.}{Passing player name.} +#' \item{`completion_yds`: integer.}{Passing yards.} +#' \item{`rush_player_id`: character.}{Rushing player reference id.} +#' \item{`rush_player`: character.}{Rushing player name.} +#' \item{`rush_yds`: integer.}{Rushing yards.} +#' \item{`interception_player_id`: character.}{Intercepting player reference id.} +#' \item{`interception_player`: character.}{Intercepting player name.} +#' \item{`interception_stat`: integer.}{Intercepting stat.} +#' \item{`interception_thrown_player_id`: character.}{Interception passing player reference id.} +#' \item{`interception_thrown_player`: character.}{Interception passing player name.} +#' \item{`interception_thrown_stat`: integer.}{Interception thrown stat.} +#' \item{`touchdown_player_id`: character.}{Touchdown scoring player reference id.} +#' \item{`touchdown_player`: character.}{Touchdown scoring player name.} +#' \item{`touchdown_stat`: integer.}{Touchdown scoring stat.} +#' \item{`incompletion_player_id`: character.}{Incomplete receiver player reference id.} +#' \item{`incompletion_player`: character.}{Incomplete receiver player name.} +#' \item{`incompletion_stat`: integer.}{Incomplete stat.} +#' \item{`target_player_id`: character.}{Targeted receiver player reference id.} +#' \item{`target_player`: character.}{Targeted receiver player name.} +#' \item{`target_stat`: integer.}{Target stat.} +#' \item{`fumble_recovered_player_id`: logical.}{Fumble recovering player reference id.} +#' \item{`fumble_recovered_player`: logical.}{Fumble recovering player name.} +#' \item{`fumble_recovered_stat`: logical.}{Fumble recovered stat.} +#' \item{`fumble_forced_player_id`: logical.}{Fumble forcing player reference id.} +#' \item{`fumble_forced_player`: logical.}{Fumble forcing player name.} +#' \item{`fumble_forced_stat`: logical.}{Fumble forced stat.} +#' \item{`fumble_player_id`: logical.}{Fumbling player reference id.} +#' \item{`fumble_player`: logical.}{Fumbling player name.} +#' \item{`fumble_stat`: logical.}{Fumble stat.} +#' \item{`sack_player_id`: character.}{Sacking player(s) reference id.} +#' \item{`sack_player`: character.}{Sacking player(s) name.} +#' \item{`sack_stat`: integer.}{Sack stat.} +#' \item{`sack_taken_player_id`: character.}{Sack taking player reference id.} +#' \item{`sack_taken_player`: character.}{Sack taking player name.} +#' \item{`sack_taken_stat`: integer.}{Sack taken stat.} +#' \item{`pass_breakup_player_id`: logical.}{Pass breakup player reference id.} +#' \item{`pass_breakup_player`: logical.}{Pass breakup player name.} +#' \item{`pass_breakup_stat`: logical.}{Pass breakup (PBU) stat.} #' } #' @source \url{https://api.collegefootballdata.com/play/stats} #' @keywords Player PBP @@ -485,13 +515,12 @@ cfbd_play_stats_player <- function(year = NULL, return(clean_df) } - -#' College Football Mapping for Play Stats Types #' @rdname cfbd_play -#' @return \code{\link[cfbfastR:cfbd_play_stats_types]{cfbfastR::cfbd_play_stats_types()}} - A data frame with 22 rows and 2 variables: +#' @title College Football Mapping for Play Stats Types +#' @return [cfbd_play_stats_types()] - A data frame with 22 rows and 2 variables: #' \describe{ -#' \item{play_stat_type_id}{Referencing play stat type ID} -#' \item{name}{Type of play stats} +#' \item{`play_stat_type_id`: integer}{Referencing play stat type ID.} +#' \item{`name`: character}{Type of play stats.} #' } #' @source \url{https://api.collegefootballdata.com/play/stat/types} #' @keywords Plays @@ -503,7 +532,6 @@ cfbd_play_stats_player <- function(year = NULL, #' \donttest{ #' cfbd_play_stats_types() #' } -#' cfbd_play_stats_types <- function() { full_url <- "https://api.collegefootballdata.com/play/stat/types" @@ -541,14 +569,13 @@ cfbd_play_stats_types <- function() { return(df) } - -#' College Football Mapping for Play Types #' @rdname cfbd_play -#' @return \code{\link[cfbfastR:cfbd_play_types]{cfbfastR::cfbd_play_types()}} - A data frame with 48 rows and 3 variables: +#' @title College Football Mapping for Play Types +#' @return [cfbd_play_types()] - A data frame with 48 rows and 3 variables: #' \describe{ -#' \item{play_type_id}{Referencing play type id} -#' \item{text}{play type description} -#' \item{abbreviation}{play type abbreviation used for function call} +#' \item{`play_type_id`: integer}{Referencing play type id.} +#' \item{`text`: character}{play type description.} +#' \item{`abbreviation`: character}{play type abbreviation used for function call} #' } #' @source \url{https://api.collegefootballdata.com/play/types} #' @importFrom jsonlite fromJSON @@ -556,9 +583,7 @@ cfbd_play_stats_types <- function() { #' @importFrom utils URLencode #' @importFrom assertthat assert_that #' @importFrom glue glue -#' - - +#' @export cfbd_play_types <- function() { full_url <- "https://api.collegefootballdata.com/play/types" diff --git a/R/cfbd_players.R b/R/cfbd_players.R index c8242cdf..35abaf4a 100644 --- a/R/cfbd_players.R +++ b/R/cfbd_players.R @@ -1,9 +1,12 @@ -#' CFBD Players Endpoint #' @name cfbd_players -NULL -#' Player Information Search -#' @rdname cfbd_players -#' +#' @aliases cfbd_player cfbd_player_info cfbd_player_returning cfbd_player_usage +#' @title CFBD Players Endpoint +#' @description +#' \describe{ +#' \item{`cfbd_player_info()`:}{Player Information Search.} +#' \item{`cfbd_player_returning()`:}{Player Returning Production} +#' \item{`cfbd_player_usage()`:}{Player Usage.} +#' } #' @param search_term (\emph{String} required): Search term for the player you are trying to look up #' @param position (\emph{string} optional): Position of the player you are searching for.\cr #' Position Group - options include:\cr @@ -14,23 +17,85 @@ NULL #' @param year (\emph{Integer} optional): Year, 4 digit format (\emph{YYYY}).\cr #' If left NULL, API default will only provide results for most recent year of final rosters: 2020 #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' @return \code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_player_info()}} - A data frame with 12 variables: +#' @return [cfbd_player_info()] - A data frame with 12 variables: #' \describe{ -#' \item{\code{athlete_id}}{character. Unique player identifier `athlete_id`.} -#' \item{\code{team}}{character. Team of the player.} -#' \item{\code{name}}{character. Player name.} -#' \item{\code{first_name}}{character. Player first name.} -#' \item{\code{last_name}}{character. Player last name.} -#' \item{\code{weight}}{integer. Player weight.} -#' \item{\code{height}}{integer. Player height.} -#' \item{\code{jersey}}{integer. Player jersey number.} -#' \item{\code{position}}{character. Player position.} -#' \item{\code{home_town}}{character. Player home town.} -#' \item{\code{team_color}}{character. Player team color.} -#' \item{\code{team_color_secondary}}{character. Player team secondary color.} +#' \item{`athlete_id`:character.}{Unique player identifier `athlete_id`.} +#' \item{`team`:character.}{Team of the player.} +#' \item{`name`:character.}{Player name.} +#' \item{`first_name`:character.}{Player first name.} +#' \item{`last_name`:character.}{Player last name.} +#' \item{`weight`:integer.}{Player weight.} +#' \item{`height`:integer.}{Player height.} +#' \item{`jersey`:integer.}{Player jersey number.} +#' \item{`position`:character.}{Player position.} +#' \item{`home_town`:character.}{Player home town.} +#' \item{`team_color`:character.}{Player team color.} +#' \item{`team_color_secondary`:character.}{Player team secondary color.} #' } #' @source \url{https://api.collegefootballdata.com/player/search} #' @keywords Players +#' @details [`cfbd_player_returning()`] +#' @param year (\emph{Integer} required, default 2019): Year, 4 digit format (\emph{YYYY}). +#' @param team (\emph{String} optional): Team - Select a valid team, D1 football +#' @param conference (\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr +#' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr +#' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC +#' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function +#' @return [cfbd_player_returning()] - A data frame with 15 variables: +#' \describe{ +#' \item{`season`:integer.}{Returning player season.} +#' \item{`team`:character.}{Team name.} +#' \item{`conference`:character.}{Conference of team.} +#' \item{`total_ppa`:double.}{Total predicted points added returning.} +#' \item{`total_passing_ppa`:double.}{Total passing predicted points added returning.} +#' \item{`total_receiving_ppa`:double.}{Total receiving predicted points added returning.} +#' \item{`total_rushing_ppa`:double.}{Total rushing predicted points added returning.} +#' \item{`percent_ppa`:double.}{Percentage of prior year's predicted points added returning.} +#' \item{`percent_passing_ppa`:double.}{Percentage of prior year's passing predicted points added returning.} +#' \item{`percent_receiving_ppa`:double.}{Percentage of prior year's receiving predicted points added returning.} +#' \item{`percent_rushing_ppa`:double.}{Percentage of prior year's rushing predicted points added returning.} +#' \item{`usage`:double.}{.} +#' \item{`passing_usage`:double.}{.} +#' \item{`receiving_usage`:double.}{.} +#' \item{`rushing_usage`:double.}{.} +#' } +#' @source \url{https://api.collegefootballdata.com/player/returning} +#' @keywords Returning Production +#' +#' @details [cfbd_player_usage()] +#' @param year (\emph{Integer} required, default 2019): Year, 4 digit format (\emph{YYYY}). +#' @param team (\emph{String} optional): Team - Select a valid team, D1 football +#' @param conference (\emph{String} optional): Conference abbreviation - Select a valid FBS conferencer\cr +#' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr +#' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC +#' @param position (\emph{string} optional): Position of the player you are searching for.\cr +#' Position Group - options include:\cr +#' * Offense: QB, RB, FB, TE, OL, G, OT, C, WR\cr +#' * Defense: DB, CB, S, LB, DE, DT, NT, DL\cr +#' * Special Teams: K, P, LS, PK +#' @param athlete_id (\emph{Integer} optional): Athlete ID filter for querying a single athlete\cr +#' Can be found using the [cfbd_player_info()] function. +#' @param excl_garbage_time (\emph{Logical} default FALSE): Select whether to exclude Garbage Time (TRUE/FALSE) +#' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function +#' @return [cfbd_player_usage()] - A data frame with 14 variables: +#' \describe{ +#' \item{`season`: integer.}{Player usage season.} +#' \item{`athlete_id`: character.}{Referencing athlete id.} +#' \item{`name`: character.}{Athlete name.} +#' \item{`position`: character.}{Athlete position.} +#' \item{`team`: character.}{Team name.} +#' \item{`conference`: character.}{Conference of team.} +#' \item{`usg_overall`: double.}{Player usage of overall offense.} +#' \item{`usg_pass`: double.}{Player passing usage percentage.} +#' \item{`usg_rush`: double.}{Player rushing usage percentage.} +#' \item{`usg_1st_down`: double.}{Player first down usage percentage.} +#' \item{`usg_2nd_down`: double.}{Player second down usage percentage.} +#' \item{`usg_3rd_down`: double.}{Player third down usage percentage.} +#' \item{`usg_standard_downs`: double.}{Player standard down usage percentage.} +#' \item{`usg_passing_downs`: double.}{Player passing down usage percentage.} +#' } +#' @source \url{https://api.collegefootballdata.com/player/usage} +#' @keywords Player Usage #' @importFrom jsonlite fromJSON #' @importFrom httr GET RETRY #' @importFrom utils URLencode @@ -136,34 +201,7 @@ cfbd_player_info <- function(search_term, } -#' Player Returning Production #' @rdname cfbd_players -#' @param year (\emph{Integer} required, default 2019): Year, 4 digit format (\emph{YYYY}). -#' @param team (\emph{String} optional): Team - Select a valid team, D1 football -#' @param conference (\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr -#' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr -#' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC -#' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' @return \code{\link[cfbfastR:cfbd_player_returning]{cfbfastR::cfbd_player_returning()}} - A data frame with 15 variables: -#' \describe{ -#' \item{\code{season}}{integer.} -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{total_ppa}}{double.} -#' \item{\code{total_passing_ppa}}{double.} -#' \item{\code{total_receiving_ppa}}{double.} -#' \item{\code{total_rushing_ppa}}{double.} -#' \item{\code{percent_ppa}}{double.} -#' \item{\code{percent_passing_ppa}}{double.} -#' \item{\code{percent_receiving_ppa}}{double.} -#' \item{\code{percent_rushing_ppa}}{double.} -#' \item{\code{usage}}{double.} -#' \item{\code{passing_usage}}{double.} -#' \item{\code{receiving_usage}}{double.} -#' \item{\code{rushing_usage}}{double.} -#' } -#' @source \url{https://api.collegefootballdata.com/player/returning} -#' @keywords Returning Production #' @importFrom jsonlite fromJSON #' @importFrom httr GET RETRY #' @importFrom utils URLencode @@ -263,41 +301,7 @@ cfbd_player_returning <- function(year = 2019, } -#' Player Usage #' @rdname cfbd_players -#' @param year (\emph{Integer} required, default 2019): Year, 4 digit format (\emph{YYYY}). -#' @param team (\emph{String} optional): Team - Select a valid team, D1 football -#' @param conference (\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr -#' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr -#' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC -#' @param position (\emph{string} optional): Position of the player you are searching for.\cr -#' Position Group - options include:\cr -#' * Offense: QB, RB, FB, TE, OL, G, OT, C, WR\cr -#' * Defense: DB, CB, S, LB, DE, DT, NT, DL\cr -#' * Special Teams: K, P, LS, PK -#' @param athlete_id (\emph{Integer} optional): Athlete ID filter for querying a single athlete\cr -#' Can be found using the \code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_player_info()}} function. -#' @param excl_garbage_time (\emph{Logical} default FALSE): Select whether to exclude Garbage Time (TRUE/FALSE) -#' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' @return \code{\link[cfbfastR:cfbd_player_usage]{cfbfastR::cfbd_player_usage()}} - A data frame with 14 variables: -#' \describe{ -#' \item{\code{season}}{integer.} -#' \item{\code{athlete_id}}{character.} -#' \item{\code{name}}{character.} -#' \item{\code{position}}{character.} -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{usg_overall}}{double.} -#' \item{\code{usg_pass}}{double.} -#' \item{\code{usg_rush}}{double.} -#' \item{\code{usg_1st_down}}{double.} -#' \item{\code{usg_2nd_down}}{double.} -#' \item{\code{usg_3rd_down}}{double.} -#' \item{\code{usg_standard_downs}}{double.} -#' \item{\code{usg_passing_downs}}{double.} -#' } -#' @source \url{https://api.collegefootballdata.com/player/usage} -#' @keywords Player Usage #' @importFrom jsonlite fromJSON #' @importFrom httr GET RETRY #' @importFrom utils URLencode diff --git a/R/cfbd_ratings.R b/R/cfbd_ratings.R index 4c111f5c..5d1850a9 100644 --- a/R/cfbd_ratings.R +++ b/R/cfbd_ratings.R @@ -1,27 +1,30 @@ -#' CFBD Ratings and Rankings Endpoints +#' #' @name cfbd_ratings -NULL -#' Gets Historical CFB poll rankings at a specific week -#' -#' Postseason polls are after Week 13 -#' @rdname cfbd_ratings -#' +#' @aliases cfbd_rankings cfbd_ratings_sp cfbd_ratings_sp_conference cfbd_ratings_srs +#' @title CFBD Ratings and Rankings Endpoints +#' @description +#' \describe{ +#' \item{`cfbd_rankings()`: Gets Historical CFB poll rankings at a specific week}{.} +#' \item{`cfbd_ratings_sp()`: Get SP historical rating data}{.} +#' \item{`cfbd_ratings_sp_conference()`: Get SP conference-level historical rating data}{.} +#' \item{`cfbd_ratings_srs()`: Get SRS historical rating data}{.} +#' } #' @param year (\emph{Integer} required): Year, 4 digit format (\emph{YYYY}) #' @param week (\emph{Integer} optional): Week, values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier) #' @param season_type (\emph{String} default regular): Season type - regular or postseason #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_rankings]{cfbfastR::cfbd_rankings()}} - A data frame with 9 variables: +#' @return [cfbd_rankings()] - A data frame with 9 variables: #' \describe{ -#' \item{\code{season}}{integer.} -#' \item{\code{season_type}}{character.} -#' \item{\code{week}}{integer.} -#' \item{\code{poll}}{character.} -#' \item{\code{rank}}{integer.} -#' \item{\code{school}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{first_place_votes}}{integer.} -#' \item{\code{points}}{integer.} +#' \item{`season`: integer.}{Rankings season.} +#' \item{`season_type`: character.}{Season type of rankings.} +#' \item{`week`: integer.}{Week of rankings.} +#' \item{`poll`: character.}{Name of the poll.} +#' \item{`rank`: integer.}{Rank in the poll.} +#' \item{`school`: character.}{Team name.} +#' \item{`conference`: character.}{Conference of the team.} +#' \item{`first_place_votes`: integer.}{Number of first place votes.} +#' \item{`points`: integer.}{Total poll points.} #' } #' @source \url{https://api.collegefootballdata.com/rankings} #' @keywords CFB Rankings @@ -126,37 +129,37 @@ cfbd_rankings <- function(year, week = NULL, season_type = "regular", #' @param team (\emph{String} optional): D-I Team #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_ratings_sp]{cfbfastR::cfbd_ratings_sp()}} - A data frame with 26 variables: +#' @return [cfbd_ratings_sp()] - A data frame with 26 variables: #' \describe{ -#' \item{\code{year}}{integer.} -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{rating}}{double.} -#' \item{\code{ranking}}{integer.} -#' \item{\code{second_order_wins}}{logical.} -#' \item{\code{sos}}{logical.} -#' \item{\code{offense_ranking}}{integer.} -#' \item{\code{offense_rating}}{double.} -#' \item{\code{offense_success}}{logical.} -#' \item{\code{offense_explosiveness}}{logical.} -#' \item{\code{offense_rushing}}{logical.} -#' \item{\code{offense_passing}}{logical.} -#' \item{\code{offense_standard_downs}}{logical.} -#' \item{\code{offense_passing_downs}}{logical.} -#' \item{\code{offense_run_rate}}{logical.} -#' \item{\code{offense_pace}}{logical.} -#' \item{\code{defense_ranking}}{integer.} -#' \item{\code{defense_rating}}{double.} -#' \item{\code{defense_success}}{logical.} -#' \item{\code{defense_explosiveness}}{logical.} -#' \item{\code{defense_rushing}}{logical.} -#' \item{\code{defense_passing}}{logical.} -#' \item{\code{defense_standard_downs}}{logical.} -#' \item{\code{defense_passing_downs}}{logical.} -#' \item{\code{defense_havoc_total}}{logical.} -#' \item{\code{defense_havoc_front_seven}}{logical.} -#' \item{\code{defense_havoc_db}}{logical.} -#' \item{\code{special_teams_rating}}{double.} +#' \item{`year`: integer.}{Season of the ratings.} +#' \item{`team`: character.}{Team name.} +#' \item{`conference`: character.}{Conference of the team.} +#' \item{`rating`: double.}{SP+ rating.} +#' \item{`ranking`: integer.}{Ranking in the SP+ ratings.} +#' \item{`second_order_wins`: logical.}{Total second-order wins - Not available for recent seasons.} +#' \item{`sos`: logical.}{Strength of schedule - Not available for recent seasons.} +#' \item{`offense_ranking`: integer.}{Overall offense ranking.} +#' \item{`offense_rating`: double.}{Overall offense rating.} +#' \item{`offense_success`: logical.}{Offense success rating - Not available for recent seasons.} +#' \item{`offense_explosiveness`: logical.}{Offense explosiveness rating - Not available for recent seasons.} +#' \item{`offense_rushing`: logical.}{Offense rushing rating - Not available for recent seasons.} +#' \item{`offense_passing`: logical.}{Offense passing rating - Not available for recent seasons.} +#' \item{`offense_standard_downs`: logical.}{Offense standard downs rating - Not available for recent seasons.} +#' \item{`offense_passing_downs`: logical.}{Offensive passing downs rating - Not available for recent seasons.} +#' \item{`offense_run_rate`: logical.}{Offense rushing rate - Not available for recent seasons.} +#' \item{`offense_pace`: logical.}{Offense pace factor - Not available for recent seasons.} +#' \item{`defense_ranking`: integer.}{Overall defense ranking.} +#' \item{`defense_rating`: double.}{Overall defense rating.} +#' \item{`defense_success`: logical.}{Defense success rating - Not available for recent seasons.} +#' \item{`defense_explosiveness`: logical.}{Defense explosiveness rating - Not available for recent seasons.} +#' \item{`defense_rushing`: logical.}{Defense rushing rating - Not available for recent seasons.} +#' \item{`defense_passing`: logical.}{Defense passing rating - Not available for recent seasons.} +#' \item{`defense_standard_downs`: logical.}{Defense standard downs rating - Not available for recent seasons.} +#' \item{`defense_passing_downs`: logical.}{Defensive passing downs rating - Not available for recent seasons.} +#' \item{`defense_havoc_total`: logical.}{Total defensive havoc rate - Not available for recent seasons.} +#' \item{`defense_havoc_front_seven`: logical.}{Defense havoc rate from front 7 players - Not available for recent seasons.} +#' \item{`defense_havoc_db`: logical.}{Defense havoc rate from defensive backs - Not available for recent seasons.} +#' \item{`special_teams_rating`: double.}{Special teams rating.} #' } #' @source \url{https://api.collegefootballdata.com/ratings/sp} #' @keywords SP+ @@ -169,7 +172,7 @@ cfbd_rankings <- function(year, week = NULL, season_type = "regular", #' @export #' @examples #' \donttest{ -#' cfbd_ratings_sp(year = 2019) +#' cfbd_ratings_sp(year = 2018) #' #' cfbd_ratings_sp(team = "Texas A&M") #' @@ -270,33 +273,34 @@ cfbd_ratings_sp <- function(year = NULL, team = NULL, #' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_ratings_sp_conference]{cfbfastR::cfbd_ratings_sp_conference()}} - A data frame with 25 variables: +#' @return [cfbd_ratings_sp_conference()] - A data frame with 25 variables: #' \describe{ -#' \item{\code{year}}{integer.} -#' \item{\code{conference}}{character.} -#' \item{\code{rating}}{double.} -#' \item{\code{second_order_wins}}{logical.} -#' \item{\code{sos}}{logical.} -#' \item{\code{offense_rating}}{double.} -#' \item{\code{offense_success}}{logical.} -#' \item{\code{offense_explosiveness}}{logical.} -#' \item{\code{offense_rushing}}{logical.} -#' \item{\code{offense_passing}}{logical.} -#' \item{\code{offense_standard_downs}}{logical.} -#' \item{\code{offense_passing_downs}}{logical.} -#' \item{\code{offense_run_rate}}{logical.} -#' \item{\code{offense_pace}}{logical.} -#' \item{\code{defense_rating}}{double.} -#' \item{\code{defense_success}}{logical.} -#' \item{\code{defense_explosiveness}}{logical.} -#' \item{\code{defense_rushing}}{logical.} -#' \item{\code{defense_passing}}{logical.} -#' \item{\code{defense_standard_downs}}{logical.} -#' \item{\code{defense_passing_downs}}{logical.} -#' \item{\code{defense_havoc_total}}{logical.} -#' \item{\code{defense_havoc_front_seven}}{logical.} -#' \item{\code{defense_havoc_db}}{logical.} -#' \item{\code{special_teams_rating}}{double.} +#' \item{`year`: integer.}{Season of the conference rating.} +#' \item{`conference`: character.}{Conference name.} +#' \item{`rating`: double.}{Conference SP+ rating.} +#' \item{`second_order_wins`: logical.}{Second-order wins for the conference - Not available for recent seasons.} +#' \item{`sos`: logical.}{Strength of schedule for the conference - Not available for recent seasons..} +#' \item{`offense_rating`: double.}{Overall offense rating for the conference.} +#' \item{`offense_success`: logical.}{Offense success rating for the conference - Not available for recent seasons.} +#' \item{`offense_explosiveness`: logical.}{Offense explosiveness rating for the conference - Not available for recent seasons.} +#' \item{`offense_rushing`: logical.}{Offense rushing rating for the conference - Not available for recent seasons.} +#' \item{`offense_passing`: logical.}{Offense passing rating for the conference - Not available for recent seasons.} +#' \item{`offense_standard_downs`: logical.}{Offense standard downs rating for the conference - Not available for recent seasons.} +#' \item{`offense_passing_downs`: logical.}{Offensive passing downs rating for the conference - Not available for recent seasons.} +#' \item{`offense_run_rate`: logical.}{Offense rushing rate for the conference - Not available for recent seasons.} +#' \item{`offense_pace`: logical.}{Offense pace factor for the conference - Not available for recent seasons.} +#' \item{`defense_ranking`: integer.}{Overall defense ranking for the conference.} +#' \item{`defense_rating`: double.}{Overall defense rating for the conference.} +#' \item{`defense_success`: logical.}{Defense success rating for the conference - Not available for recent seasons.} +#' \item{`defense_explosiveness`: logical.}{Defense explosiveness rating for the conference - Not available for recent seasons.} +#' \item{`defense_rushing`: logical.}{Defense rushing rating for the conference - Not available for recent seasons.} +#' \item{`defense_passing`: logical.}{Defense passing rating for the conference - Not available for recent seasons.} +#' \item{`defense_standard_downs`: logical.}{Defense standard downs rating for the conference - Not available for recent seasons.} +#' \item{`defense_passing_downs`: logical.}{Defensive passing downs rating for the conference - Not available for recent seasons.} +#' \item{`defense_havoc_total`: logical.}{Total defensive havoc rate for the conference - Not available for recent seasons.} +#' \item{`defense_havoc_front_seven`: logical.}{Defense havoc rate from front 7 players for the conference - Not available for recent seasons.} +#' \item{`defense_havoc_db`: logical.}{Defense havoc rate from defensive backs for the conference - Not available for recent seasons.} +#' \item{`special_teams_rating`: double.}{Special teams rating for the conference.} #' } #' @source \url{https://api.collegefootballdata.com/ratings/sp/conferences} #' @keywords SP+ @@ -413,14 +417,14 @@ cfbd_ratings_sp_conference <- function(year = NULL, conference = NULL, #' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_ratings_srs]{cfbfastR::cfbd_ratings_srs()}} - A data frame with 6 variables: +#' @return [cfbd_ratings_srs()] - A data frame with 6 variables: #' \describe{ -#' \item{\code{year}}{integer.} -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{division}}{logical.} -#' \item{\code{rating}}{double.} -#' \item{\code{ranking}}{integer.} +#' \item{`year`: integer.}{Season of the SRS rating.} +#' \item{`team`: character.}{Team name.} +#' \item{`conference`: character.}{Conference of the team.} +#' \item{`division`: logical.}{Division in the conference for the team.} +#' \item{`rating`: double.}{Simple Rating System (SRS) rating.} +#' \item{`ranking`: integer.}{Simple Rating System ranking within the group returned.} #' } #' @source \url{https://api.collegefootballdata.com/ratings/srs} #' @keywords SRS diff --git a/R/cfbd_recruiting.R b/R/cfbd_recruiting.R index 3671c7da..2b85f298 100644 --- a/R/cfbd_recruiting.R +++ b/R/cfbd_recruiting.R @@ -1,19 +1,32 @@ -#' CFBD Recruiting Endpoint + #' @name cfbd_recruiting -NULL -#' CFB Recruiting +#' @aliases cfbd_recruiting recruiting cfbd_recruiting_player cfbd_recruiting_position cfbd_recruiting_team +#' @title CFB Recruiting Endpoint +#' @description +#' \describe{ +#' \item{`cfbd_recruiting_player()`: Gets CFB recruiting information for a single year with filters available for team, recruit type, state and position.}{} +#' +#' \item{`cfbd_recruiting_position()`: CFB Recruiting Information Position Groups.}{} +#' +#' \item{`cfbd_recruiting_team()`: CFB Recruiting Information Team Rankings.}{} +#' } +#' +#' @details +#' +#' Gets CFB team recruiting ranks with filters available for year and team. +#' At least one of \strong{year} or \strong{team} must be specified for the function to run #' -#' Gets CFB recruiting information for a single year with filters available for team, -#' recruit type, state and position. +#' If you would like CFB recruiting information for players, please +#' see the [cfbd_recruiting_player()] function #' -#' At least one of \strong{year} or \strong{team} must be specified for the function to run +#' If you would like to get CFB recruiting information based on position groups during a +#' time period for all FBS teams, please see the [cfbd_recruiting_position()] function. #' -#' If you would like CFB recruiting information for teams, please see the \code{\link[cfbfastR:cfbd_recruiting_team]{cfbfastR::cfbd_recruiting_team()}} function +#' [cfbd_recruiting_player()] - At least one of \strong{year} or \strong{team} must be specified for the function to run #' -#' If you would like to get cfb recruiting information based on position groups during a -#' time period for all FBS teams, please see the \code{\link[cfbfastR:cfbd_recruiting_position]{cfbfastR::cfbd_recruiting_position()}} function. +#' [cfbd_recruiting_position()] - If only start_year is provided, function will get CFB recruiting information based +#' on position groups during that year for all FBS teams. #' -#' @rdname cfbd_recruiting #' @param year (\emph{Integer} optional): Year, 4 digit format (\emph{YYYY}) - Minimum: 2000, Maximum: 2020 currently #' @param team (\emph{String} optional): D-I Team #' @param recruit_type (\emph{String} optional): default API return is 'HighSchool', other options include 'JUCO' @@ -25,25 +38,25 @@ NULL #' * Special Teams: 'K', 'P' #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_recruiting_player]{cfbfastR::cfbd_recruiting_player()}} - A data frame with 14 variables: +#' @return [cfbd_recruiting_player()] - A data frame with 14 variables: #' \describe{ -#' \item{\code{recruit_type}}{character.} -#' \item{\code{year}}{integer.} -#' \item{\code{ranking}}{integer.} -#' \item{\code{name}}{character.} -#' \item{\code{school}}{character.} -#' \item{\code{committed_to}}{character.} -#' \item{\code{position}}{character.} -#' \item{\code{height}}{double.} -#' \item{\code{weight}}{integer.} -#' \item{\code{stars}}{integer.} -#' \item{\code{rating}}{double.} -#' \item{\code{city}}{character.} -#' \item{\code{state_province}}{character.} -#' \item{\code{country}}{character.} -#' \item{\code{hometown_info_latitude}}{character.} -#' \item{\code{hometown_info_longitude}}{character.} -#' \item{\code{hometown_info_fips_code}}{character.} +#' \item{`recruit_type`: character.}{High School, Prep School, or Junior College.} +#' \item{`year`: integer.}{Recruit class year.} +#' \item{`ranking`: integer.}{Recruit Ranking.} +#' \item{`name`: character.}{Recruit Name.} +#' \item{`school`: character.}{School recruit attended.} +#' \item{`committed_to`: character.}{School the recruit is committed to.} +#' \item{`position`: character.}{Recruit position.} +#' \item{`height`: double.}{Recruit height.} +#' \item{`weight`: integer.}{Recruit weight.} +#' \item{`stars`: integer.}{Recruit stars.} +#' \item{`rating`: double.}{247 composite rating.} +#' \item{`city`: character.}{Hometown of the recruit.} +#' \item{`state_province`: character.}{Hometown state of the recruit.} +#' \item{`country`: character.}{Hometown country of the recruit.} +#' \item{`hometown_info_latitude`: character.}{Hometown latitude.} +#' \item{`hometown_info_longitude`: character.}{Hometown longitude.} +#' \item{`hometown_info_fips_code`: character.}{Hometown FIPS code.} #' } #' @source \url{https://api.collegefootballdata.com/recruiting/players} #' @keywords Recruiting @@ -157,17 +170,6 @@ cfbd_recruiting_player <- function(year = NULL, return(df) } -#' CFB Recruiting Information Position Groups -#' -#' If only start_year is provided, function will get CFB recruiting information based -#' on position groups during that year for all FBS teams. -#' -#' If you would like CFB recruiting information for players, please -#' see the \code{\link[cfbfastR:cfbd_recruiting_player]{cfbfastR::cfbd_recruiting_player()}} function -#' -#' If you would like CFB recruiting information for teams, please -#' see the \code{\link[cfbfastR:cfbd_recruiting_team]{cfbfastR::cfbd_recruiting_team()}} function -#' #' @rdname cfbd_recruiting #' @param start_year (\emph{Integer} optional): Start Year, 4 digit format (\emph{YYYY}). \emph{Note: 2000 is the minimum value} #' @param end_year (\emph{Integer} optional): End Year, 4 digit format (\emph{YYYY}). \emph{Note: 2020 is the maximum value currently} @@ -177,15 +179,15 @@ cfbd_recruiting_player <- function(year = NULL, #' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_recruiting_position]{cfbfastR::cfbd_recruiting_position()}} - A data frame with 7 variables: +#' @return [cfbd_recruiting_position()] - A data frame with 7 variables: #' \describe{ -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{position_group}}{character.} -#' \item{\code{avg_rating}}{double.} -#' \item{\code{total_rating}}{double.} -#' \item{\code{commits}}{integer.} -#' \item{\code{avg_stars}}{double.} +#' \item{`team`: character.}{Recruiting team.} +#' \item{`conference`: character.}{Recruiting team conference.} +#' \item{`position_group`: character.}{Position group of the recruits.} +#' \item{`avg_rating`: double.}{Average rating of the recruits in the position group.} +#' \item{`total_rating`: double.}{Sum of the ratings of the recruits in the position group.} +#' \item{`commits`: integer.}{Number of commits in the position group.} +#' \item{`avg_stars`: double.}{Average stars of the recruits in the position group.} #' } #' @source \url{https://api.collegefootballdata.com/recruiting/groups} #' @keywords Recruiting @@ -293,28 +295,17 @@ cfbd_recruiting_position <- function(start_year = NULL, end_year = NULL, return(df) } -#' CFB Recruiting Information Team Rankings -#' -#' Gets CFB team recruiting ranks with filters available for year and team. -#' At least one of \strong{year} or \strong{team} must be specified for the function to run -#' -#' If you would like CFB recruiting information for players, please -#' see the \code{\link[cfbfastR:cfbd_recruiting_player]{cfbfastR::cfbd_recruiting_player()}} function -#' -#' If you would like to get CFB recruiting information based on position groups during a -#' time period for all FBS teams, please see the \code{\link[cfbfastR:cfbd_recruiting_position]{cfbfastR::cfbd_recruiting_position()}} function. -#' #' @rdname cfbd_recruiting #' @param year (\emph{Integer} optional): Recruiting Class Year, 4 digit format (\emph{YYYY}). \emph{Note: 2000 is the minimum value} #' @param team (\emph{String} optional): Team - Select a valid team, D1 football #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_recruiting_team]{cfbfastR::cfbd_recruiting_team()}} - A data frame with 4 variables: +#' @return [cfbd_recruiting_team()] - A data frame with 4 variables: #' \describe{ -#' \item{\code{year}}{integer.} -#' \item{\code{rank}}{integer.} -#' \item{\code{team}}{character.} -#' \item{\code{points}}{character.} +#' \item{`year`: integer.}{Recruiting class year.} +#' \item{`rank`: integer.}{Team Recruiting rank.} +#' \item{`team`: character.}{Recruiting Team.} +#' \item{`points`: character.}{Team talent points.} #' } #' @source \url{https://api.collegefootballdata.com/recruiting/teams} #' @keywords Recruiting diff --git a/R/cfbd_stats.R b/R/cfbd_stats.R index dba0d63b..a68a1d35 100644 --- a/R/cfbd_stats.R +++ b/R/cfbd_stats.R @@ -1,11 +1,15 @@ -#' CFBD Stats Endpoint #' @name cfbd_stats -NULL -#' College Football Mapping for Stats Categories -#' -#' This function identifies all Stats Categories identified in the regular stats endpoint. -#' -#' @rdname cfbd_stats +#' @aliases cfbd_stats_categories cfbd_stats_game_advanced cfbd_stats_season_advanced cfbd_stats_season_player cfbd_stats_season_team +#' @title CFBD Stats Endpoint +#' @description +#' \describe{ +#' \item{`cfbd_stats_categories()`: College Football Mapping for Stats Categories}{.} +#' \item{`cfbd_stats_season_team()`: Get Season Statistics by Team}{.} +#' \item{`cfbd_stats_season_advanced()`: Get Season Advanced Statistics by Team}{.} +#' \item{`cfbd_stats_game_advanced()`: Get Game Advanced Stats}{.} +#' \item{`cfbd_stats_season_player()`: Get Season Statistics by Player}{.} +#' } +#' @description [cfbd_stats_categories()] This function identifies all Stats Categories identified in the regular stats endpoint. #' @examples #' \donttest{ #' cfbd_stats_categories() @@ -83,66 +87,66 @@ cfbd_stats_categories <- function() { #' } #' @return [cfbd_stats_game_advanced()] - A data frame with 60 variables: #' \describe{ -#' \item{\code{game_id}}{integer.} -#' \item{\code{week}}{integer.} -#' \item{\code{team}}{character.} -#' \item{\code{opponent}}{character.} -#' \item{\code{off_plays}}{integer.} -#' \item{\code{off_drives}}{integer.} -#' \item{\code{off_ppa}}{double.} -#' \item{\code{off_total_ppa}}{double.} -#' \item{\code{off_success_rate}}{double.} -#' \item{\code{off_explosiveness}}{double.} -#' \item{\code{off_power_success}}{double.} -#' \item{\code{off_stuff_rate}}{double.} -#' \item{\code{off_line_yds}}{double.} -#' \item{\code{off_line_yds_total}}{integer.} -#' \item{\code{off_second_lvl_yds}}{double.} -#' \item{\code{off_second_lvl_yds_total}}{integer.} -#' \item{\code{off_open_field_yds}}{integer.} -#' \item{\code{off_open_field_yds_total}}{integer.} -#' \item{\code{off_standard_downs_ppa}}{double.} -#' \item{\code{off_standard_downs_success_rate}}{double.} -#' \item{\code{off_standard_downs_explosiveness}}{double.} -#' \item{\code{off_passing_downs_ppa}}{double.} -#' \item{\code{off_passing_downs_success_rate}}{double.} -#' \item{\code{off_passing_downs_explosiveness}}{double.} -#' \item{\code{off_rushing_plays_ppa}}{double.} -#' \item{\code{off_rushing_plays_total_ppa}}{double.} -#' \item{\code{off_rushing_plays_success_rate}}{double.} -#' \item{\code{off_rushing_plays_explosiveness}}{double.} -#' \item{\code{off_passing_plays_ppa}}{double.} -#' \item{\code{off_passing_plays_total_ppa}}{double.} -#' \item{\code{off_passing_plays_success_rate}}{double.} -#' \item{\code{off_passing_plays_explosiveness}}{double.} -#' \item{\code{def_plays}}{integer.} -#' \item{\code{def_drives}}{integer.} -#' \item{\code{def_ppa}}{double.} -#' \item{\code{def_total_ppa}}{double.} -#' \item{\code{def_success_rate}}{double.} -#' \item{\code{def_explosiveness}}{double.} -#' \item{\code{def_power_success}}{double.} -#' \item{\code{def_stuff_rate}}{double.} -#' \item{\code{def_line_yds}}{double.} -#' \item{\code{def_line_yds_total}}{integer.} -#' \item{\code{def_second_lvl_yds}}{double.} -#' \item{\code{def_second_lvl_yds_total}}{integer.} -#' \item{\code{def_open_field_yds}}{double.} -#' \item{\code{def_open_field_yds_total}}{integer.} -#' \item{\code{def_standard_downs_ppa}}{double.} -#' \item{\code{def_standard_downs_success_rate}}{double.} -#' \item{\code{def_standard_downs_explosiveness}}{double.} -#' \item{\code{def_passing_downs_ppa}}{double.} -#' \item{\code{def_passing_downs_success_rate}}{double.} -#' \item{\code{def_passing_downs_explosiveness}}{double.} -#' \item{\code{def_rushing_plays_ppa}}{double.} -#' \item{\code{def_rushing_plays_total_ppa}}{double.} -#' \item{\code{def_rushing_plays_success_rate}}{double.} -#' \item{\code{def_rushing_plays_explosiveness}}{double.} -#' \item{\code{def_passing_plays_ppa}}{double.} -#' \item{\code{def_passing_plays_total_ppa}}{double.} -#' \item{\code{def_passing_plays_success_rate}}{double.} -#' \item{\code{def_passing_plays_explosiveness}}{double.} +#' \item{`game_id`: integer.}{.} +#' \item{`week`: integer.}{.} +#' \item{`team`: character.}{.} +#' \item{`opponent`: character.}{.} +#' \item{`off_plays`: integer.}{.} +#' \item{`off_drives`: integer.}{.} +#' \item{`off_ppa`: double.}{.} +#' \item{`off_total_ppa`: double.}{.} +#' \item{`off_success_rate`: double.}{.} +#' \item{`off_explosiveness`: double.}{.} +#' \item{`off_power_success`: double.}{.} +#' \item{`off_stuff_rate`: double.}{.} +#' \item{`off_line_yds`: double.}{.} +#' \item{`off_line_yds_total`: integer.}{.} +#' \item{`off_second_lvl_yds`: double.}{.} +#' \item{`off_second_lvl_yds_total`: integer.}{.} +#' \item{`off_open_field_yds`: integer.}{.} +#' \item{`off_open_field_yds_total`: integer.}{.} +#' \item{`off_standard_downs_ppa`: double.}{.} +#' \item{`off_standard_downs_success_rate`: double.}{.} +#' \item{`off_standard_downs_explosiveness`: double.}{.} +#' \item{`off_passing_downs_ppa`: double.}{.} +#' \item{`off_passing_downs_success_rate`: double.}{.} +#' \item{`off_passing_downs_explosiveness`: double.}{.} +#' \item{`off_rushing_plays_ppa`: double.}{.} +#' \item{`off_rushing_plays_total_ppa`: double.}{.} +#' \item{`off_rushing_plays_success_rate`: double.}{.} +#' \item{`off_rushing_plays_explosiveness`: double.}{.} +#' \item{`off_passing_plays_ppa`: double.}{.} +#' \item{`off_passing_plays_total_ppa`: double.}{.} +#' \item{`off_passing_plays_success_rate`: double.}{.} +#' \item{`off_passing_plays_explosiveness`: double.}{.} +#' \item{`def_plays`: integer.}{.} +#' \item{`def_drives`: integer.}{.} +#' \item{`def_ppa`: double.}{.} +#' \item{`def_total_ppa`: double.}{.} +#' \item{`def_success_rate`: double.}{.} +#' \item{`def_explosiveness`: double.}{.} +#' \item{`def_power_success`: double.}{.} +#' \item{`def_stuff_rate`: double.}{.} +#' \item{`def_line_yds`: double.}{.} +#' \item{`def_line_yds_total`: integer.}{.} +#' \item{`def_second_lvl_yds`: double.}{.} +#' \item{`def_second_lvl_yds_total`: integer.}{.} +#' \item{`def_open_field_yds`: double.}{.} +#' \item{`def_open_field_yds_total`: integer.}{.} +#' \item{`def_standard_downs_ppa`: double.}{.} +#' \item{`def_standard_downs_success_rate`: double.}{.} +#' \item{`def_standard_downs_explosiveness`: double.}{.} +#' \item{`def_passing_downs_ppa`: double.}{.} +#' \item{`def_passing_downs_success_rate`: double.}{.} +#' \item{`def_passing_downs_explosiveness`: double.}{.} +#' \item{`def_rushing_plays_ppa`: double.}{.} +#' \item{`def_rushing_plays_total_ppa`: double.}{.} +#' \item{`def_rushing_plays_success_rate`: double.}{.} +#' \item{`def_rushing_plays_explosiveness`: double.}{.} +#' \item{`def_passing_plays_ppa`: double.}{.} +#' \item{`def_passing_plays_total_ppa`: double.}{.} +#' \item{`def_passing_plays_success_rate`: double.}{.} +#' \item{`def_passing_plays_explosiveness`: double.}{.} #' } #' @source \url{https://api.collegefootballdata.com/stats/game/advanced} #' @keywords Game Advanced Stats @@ -294,85 +298,85 @@ cfbd_stats_game_advanced <- function(year, #' } #' @return [cfbd_stats_season_advanced()] - A data frame with 79 variables: #' \describe{ -#' \item{\code{season}}{integer.} -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{off_plays}}{integer.} -#' \item{\code{off_drives}}{integer.} -#' \item{\code{off_ppa}}{double.} -#' \item{\code{off_total_ppa}}{double.} -#' \item{\code{off_success_rate}}{double.} -#' \item{\code{off_explosiveness}}{double.} -#' \item{\code{off_power_success}}{double.} -#' \item{\code{off_stuff_rate}}{double.} -#' \item{\code{off_line_yds}}{double.} -#' \item{\code{off_line_yds_total}}{integer.} -#' \item{\code{off_second_lvl_yds}}{double.} -#' \item{\code{off_second_lvl_yds_total}}{integer.} -#' \item{\code{off_open_field_yds}}{double.} -#' \item{\code{off_open_field_yds_total}}{integer.} -#' \item{\code{off_pts_per_opp}}{double.} -#' \item{\code{off_field_pos_avg_start}}{double.} -#' \item{\code{off_field_pos_avg_predicted_points}}{double.} -#' \item{\code{off_havoc_total}}{double.} -#' \item{\code{off_havoc_front_seven}}{double.} -#' \item{\code{off_havoc_db}}{double.} -#' \item{\code{off_standard_downs_rate}}{double.} -#' \item{\code{off_standard_downs_ppa}}{double.} -#' \item{\code{off_standard_downs_success_rate}}{double.} -#' \item{\code{off_standard_downs_explosiveness}}{double.} -#' \item{\code{off_passing_downs_rate}}{double.} -#' \item{\code{off_passing_downs_ppa}}{double.} -#' \item{\code{off_passing_downs_success_rate}}{double.} -#' \item{\code{off_passing_downs_explosiveness}}{double.} -#' \item{\code{off_rushing_plays_rate}}{double.} -#' \item{\code{off_rushing_plays_ppa}}{double.} -#' \item{\code{off_rushing_plays_total_ppa}}{double.} -#' \item{\code{off_rushing_plays_success_rate}}{double.} -#' \item{\code{off_rushing_plays_explosiveness}}{double.} -#' \item{\code{off_passing_plays_rate}}{double.} -#' \item{\code{off_passing_plays_ppa}}{double.} -#' \item{\code{off_passing_plays_total_ppa}}{double.} -#' \item{\code{off_passing_plays_success_rate}}{double.} -#' \item{\code{off_passing_plays_explosiveness}}{double.} -#' \item{\code{def_plays}}{integer.} -#' \item{\code{def_drives}}{integer.} -#' \item{\code{def_ppa}}{double.} -#' \item{\code{def_total_ppa}}{double.} -#' \item{\code{def_success_rate}}{double.} -#' \item{\code{def_explosiveness}}{double.} -#' \item{\code{def_power_success}}{double.} -#' \item{\code{def_stuff_rate}}{double.} -#' \item{\code{def_line_yds}}{double.} -#' \item{\code{def_line_yds_total}}{integer.} -#' \item{\code{def_second_lvl_yds}}{double.} -#' \item{\code{def_second_lvl_yds_total}}{integer.} -#' \item{\code{def_open_field_yds}}{double.} -#' \item{\code{def_open_field_yds_total}}{integer.} -#' \item{\code{def_pts_per_opp}}{double.} -#' \item{\code{def_field_pos_avg_start}}{integer.} -#' \item{\code{def_field_pos_avg_predicted_points}}{double.} -#' \item{\code{def_havoc_total}}{double.} -#' \item{\code{def_havoc_front_seven}}{double.} -#' \item{\code{def_havoc_db}}{double.} -#' \item{\code{def_standard_downs_rate}}{double.} -#' \item{\code{def_standard_downs_ppa}}{double.} -#' \item{\code{def_standard_downs_success_rate}}{double.} -#' \item{\code{def_standard_downs_explosiveness}}{double.} -#' \item{\code{def_passing_downs_rate}}{double.} -#' \item{\code{def_passing_downs_ppa}}{double.} -#' \item{\code{def_passing_downs_total_ppa}}{double.} -#' \item{\code{def_passing_downs_success_rate}}{double.} -#' \item{\code{def_passing_downs_explosiveness}}{double.} -#' \item{\code{def_rushing_plays_rate}}{double.} -#' \item{\code{def_rushing_plays_ppa}}{double.} -#' \item{\code{def_rushing_plays_total_ppa}}{double.} -#' \item{\code{def_rushing_plays_success_rate}}{double.} -#' \item{\code{def_rushing_plays_explosiveness}}{double.} -#' \item{\code{def_passing_plays_rate}}{double.} -#' \item{\code{def_passing_plays_ppa}}{double.} -#' \item{\code{def_passing_plays_success_rate}}{double.} -#' \item{\code{def_passing_plays_explosiveness}}{double.} +#' \item{`season`: integer.}{.} +#' \item{`team`: character.}{.} +#' \item{`conference`: character.}{.} +#' \item{`off_plays`: integer.}{.} +#' \item{`off_drives`: integer.}{.} +#' \item{`off_ppa`: double.}{.} +#' \item{`off_total_ppa`: double.}{.} +#' \item{`off_success_rate`: double.}{.} +#' \item{`off_explosiveness`: double.}{.} +#' \item{`off_power_success`: double.}{.} +#' \item{`off_stuff_rate`: double.}{.} +#' \item{`off_line_yds`: double.}{.} +#' \item{`off_line_yds_total`: integer.}{.} +#' \item{`off_second_lvl_yds`: double.}{.} +#' \item{`off_second_lvl_yds_total`: integer.}{.} +#' \item{`off_open_field_yds`: double.}{.} +#' \item{`off_open_field_yds_total`: integer.}{.} +#' \item{`off_pts_per_opp`: double.}{.} +#' \item{`off_field_pos_avg_start`: double.}{.} +#' \item{`off_field_pos_avg_predicted_points`: double.}{.} +#' \item{`off_havoc_total`: double.}{.} +#' \item{`off_havoc_front_seven`: double.}{.} +#' \item{`off_havoc_db`: double.}{.} +#' \item{`off_standard_downs_rate`: double.}{.} +#' \item{`off_standard_downs_ppa`: double.}{.} +#' \item{`off_standard_downs_success_rate`: double.}{.} +#' \item{`off_standard_downs_explosiveness`: double.}{.} +#' \item{`off_passing_downs_rate`: double.}{.} +#' \item{`off_passing_downs_ppa`: double.}{.} +#' \item{`off_passing_downs_success_rate`: double.}{.} +#' \item{`off_passing_downs_explosiveness`: double.}{.} +#' \item{`off_rushing_plays_rate`: double.}{.} +#' \item{`off_rushing_plays_ppa`: double.}{.} +#' \item{`off_rushing_plays_total_ppa`: double.}{.} +#' \item{`off_rushing_plays_success_rate`: double.}{.} +#' \item{`off_rushing_plays_explosiveness`: double.}{.} +#' \item{`off_passing_plays_rate`: double.}{.} +#' \item{`off_passing_plays_ppa`: double.}{.} +#' \item{`off_passing_plays_total_ppa`: double.}{.} +#' \item{`off_passing_plays_success_rate`: double.}{.} +#' \item{`off_passing_plays_explosiveness`: double.}{.} +#' \item{`def_plays`: integer.}{.} +#' \item{`def_drives`: integer.}{.} +#' \item{`def_ppa`: double.}{.} +#' \item{`def_total_ppa`: double.}{.} +#' \item{`def_success_rate`: double.}{.} +#' \item{`def_explosiveness`: double.}{.} +#' \item{`def_power_success`: double.}{.} +#' \item{`def_stuff_rate`: double.}{.} +#' \item{`def_line_yds`: double.}{.} +#' \item{`def_line_yds_total`: integer.}{.} +#' \item{`def_second_lvl_yds`: double.}{.} +#' \item{`def_second_lvl_yds_total`: integer.}{.} +#' \item{`def_open_field_yds`: double.}{.} +#' \item{`def_open_field_yds_total`: integer.}{.} +#' \item{`def_pts_per_opp`: double.}{.} +#' \item{`def_field_pos_avg_start`: integer.}{.} +#' \item{`def_field_pos_avg_predicted_points`: double.}{.} +#' \item{`def_havoc_total`: double.}{.} +#' \item{`def_havoc_front_seven`: double.}{.} +#' \item{`def_havoc_db`: double.}{.} +#' \item{`def_standard_downs_rate`: double.}{.} +#' \item{`def_standard_downs_ppa`: double.}{.} +#' \item{`def_standard_downs_success_rate`: double.}{.} +#' \item{`def_standard_downs_explosiveness`: double.}{.} +#' \item{`def_passing_downs_rate`: double.}{.} +#' \item{`def_passing_downs_ppa`: double.}{.} +#' \item{`def_passing_downs_total_ppa`: double.}{.} +#' \item{`def_passing_downs_success_rate`: double.}{.} +#' \item{`def_passing_downs_explosiveness`: double.}{.} +#' \item{`def_rushing_plays_rate`:double.}{.} +#' \item{`def_rushing_plays_ppa`:double.}{.} +#' \item{`def_rushing_plays_total_ppa`:double.}{.} +#' \item{`def_rushing_plays_success_rate`:double.}{.} +#' \item{`def_rushing_plays_explosiveness`:double.}{.} +#' \item{`def_passing_plays_rate`:double.}{.} +#' \item{`def_passing_plays_ppa`:double.}{.} +#' \item{`def_passing_plays_success_rate`:double.}{.} +#' \item{`def_passing_plays_explosiveness`:double.}{.} #' } #' @source \url{https://api.collegefootballdata.com/stats/season/advanced} #' @keywords Team Season Advanced Stats @@ -530,65 +534,65 @@ cfbd_stats_season_advanced <- function(year, #' } #' @return [cfbd_stats_season_player()] - A data frame with 59 variables: #' \describe{ -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{athlete_id}}{character.} -#' \item{\code{player}}{character.} -#' \item{\code{category}}{character.} -#' \item{\code{passing_completions}}{double.} -#' \item{\code{passing_att}}{double.} -#' \item{\code{passing_pct}}{double.} -#' \item{\code{passing_yds}}{double.} -#' \item{\code{passing_td}}{double.} -#' \item{\code{passing_int}}{double.} -#' \item{\code{passing_ypa}}{double.} -#' \item{\code{rushing_car}}{double.} -#' \item{\code{rushing_yds}}{double.} -#' \item{\code{rushing_td}}{double.} -#' \item{\code{rushing_ypc}}{double.} -#' \item{\code{rushing_long}}{double.} -#' \item{\code{receiving_rec}}{double.} -#' \item{\code{receiving_yds}}{double.} -#' \item{\code{receiving_td}}{double.} -#' \item{\code{receiving_ypr}}{double.} -#' \item{\code{receiving_long}}{double.} -#' \item{\code{fumbles_fum}}{double.} -#' \item{\code{fumbles_rec}}{double.} -#' \item{\code{fumbles_lost}}{double.} -#' \item{\code{defensive_solo}}{double.} -#' \item{\code{defensive_tot}}{double.} -#' \item{\code{defensive_tfl}}{double.} -#' \item{\code{defensive_sacks}}{double.} -#' \item{\code{defensive_qb_hur}}{double.} -#' \item{\code{interceptions_int}}{double.} -#' \item{\code{interceptions_yds}}{double.} -#' \item{\code{interceptions_avg}}{double.} -#' \item{\code{interceptions_td}}{double.} -#' \item{\code{defensive_pd}}{double.} -#' \item{\code{defensive_td}}{double.} -#' \item{\code{kicking_fgm}}{double.} -#' \item{\code{kicking_fga}}{double.} -#' \item{\code{kicking_pct}}{double.} -#' \item{\code{kicking_xpa}}{double.} -#' \item{\code{kicking_xpm}}{double.} -#' \item{\code{kicking_pts}}{double.} -#' \item{\code{kicking_long}}{double.} -#' \item{\code{kick_returns_no}}{double.} -#' \item{\code{kick_returns_yds}}{double.} -#' \item{\code{kick_returns_avg}}{double.} -#' \item{\code{kick_returns_td}}{double.} -#' \item{\code{kick_returns_long}}{double.} -#' \item{\code{punting_no}}{double.} -#' \item{\code{punting_yds}}{double.} -#' \item{\code{punting_ypp}}{double.} -#' \item{\code{punting_long}}{double.} -#' \item{\code{punting_in_20}}{double.} -#' \item{\code{punting_tb}}{double.} -#' \item{\code{punt_returns_no}}{double.} -#' \item{\code{punt_returns_yds}}{double.} -#' \item{\code{punt_returns_avg}}{double.} -#' \item{\code{punt_returns_td}}{double.} -#' \item{\code{punt_returns_long}}{double.} +#' \item{`team`: character.}{.} +#' \item{`conference`: character.}{.} +#' \item{`athlete_id`: character.}{.} +#' \item{`player`: character.}{.} +#' \item{`category`: character.}{.} +#' \item{`passing_completions`: double.}{.} +#' \item{`passing_att`: double.}{.} +#' \item{`passing_pct`: double.}{.} +#' \item{`passing_yds`: double.}{.} +#' \item{`passing_td`: double.}{.} +#' \item{`passing_int`: double.}{.} +#' \item{`passing_ypa`: double.}{.} +#' \item{`rushing_car`: double.}{.} +#' \item{`rushing_yds`: double.}{.} +#' \item{`rushing_td`: double.}{.} +#' \item{`rushing_ypc`: double.}{.} +#' \item{`rushing_long`: double.}{.} +#' \item{`receiving_rec`: double.}{.} +#' \item{`receiving_yds`: double.}{.} +#' \item{`receiving_td`: double.}{.} +#' \item{`receiving_ypr`: double.}{.} +#' \item{`receiving_long`: double.}{.} +#' \item{`fumbles_fum`: double.}{.} +#' \item{`fumbles_rec`: double.}{.} +#' \item{`fumbles_lost`: double.}{.} +#' \item{`defensive_solo`: double.}{.} +#' \item{`defensive_tot`: double.}{.} +#' \item{`defensive_tfl`: double.}{.} +#' \item{`defensive_sacks`: double.}{.} +#' \item{`defensive_qb_hur`: double.}{.} +#' \item{`interceptions_int`: double.}{.} +#' \item{`interceptions_yds`: double.}{.} +#' \item{`interceptions_avg`: double.}{.} +#' \item{`interceptions_td`: double.}{.} +#' \item{`defensive_pd`: double.}{.} +#' \item{`defensive_td`: double.}{.} +#' \item{`kicking_fgm`: double.}{.} +#' \item{`kicking_fga`: double.}{.} +#' \item{`kicking_pct`: double.}{.} +#' \item{`kicking_xpa`: double.}{.} +#' \item{`kicking_xpm`: double.}{.} +#' \item{`kicking_pts`: double.}{.} +#' \item{`kicking_long`: double.}{.} +#' \item{`kick_returns_no`: double.}{.} +#' \item{`kick_returns_yds`: double.}{.} +#' \item{`kick_returns_avg`: double.}{.} +#' \item{`kick_returns_td`: double.}{.} +#' \item{`kick_returns_long`: double.}{.} +#' \item{`punting_no`: double.}{.} +#' \item{`punting_yds`: double.}{.} +#' \item{`punting_ypp`: double.}{.} +#' \item{`punting_long`: double.}{.} +#' \item{`punting_in_20`: double.}{.} +#' \item{`punting_tb`: double.}{.} +#' \item{`punt_returns_no`: double.}{.} +#' \item{`punt_returns_yds`: double.}{.} +#' \item{`punt_returns_avg`: double.}{.} +#' \item{`punt_returns_td`: double.}{.} +#' \item{`punt_returns_long`: double.}{.} #' } #' @source \url{https://api.collegefootballdata.com/stats/player/season} #' @keywords Player Season Stats @@ -798,52 +802,52 @@ cfbd_stats_season_player <- function(year, #' } #' @return [cfbd_stats_season_team()] - A data frame with 46 variables: #' \describe{ -#' \item{\code{games}}{integer.} -#' \item{\code{team}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{games}}{integer.} -#' \item{\code{time_of_poss_total}}{integer.} -#' \item{\code{time_of_poss_pg}}{double.} -#' \item{\code{pass_comps}}{integer.} -#' \item{\code{pass_atts}}{integer.} -#' \item{\code{completion_pct}}{double.} -#' \item{\code{net_pass_yds}}{integer.} -#' \item{\code{pass_ypa}}{double.} -#' \item{\code{pass_ypr}}{double.} -#' \item{\code{pass_TDs}}{integer.} -#' \item{\code{interceptions}}{integer.} -#' \item{\code{int_pct}}{double.} -#' \item{\code{rush_atts}}{integer.} -#' \item{\code{rush_yds}}{integer.} -#' \item{\code{rush_TDs}}{integer.} -#' \item{\code{rush_ypc}}{double.} -#' \item{\code{total_yds}}{integer.} -#' \item{\code{fumbles_lost}}{integer.} -#' \item{\code{turnovers}}{integer.} -#' \item{\code{turnovers_pg}}{double.} -#' \item{\code{first_downs}}{integer.} -#' \item{\code{third_downs}}{integer.} -#' \item{\code{third_down_convs}}{integer.} -#' \item{\code{third_conv_rate}}{double.} -#' \item{\code{fourth_down_convs}}{integer.} -#' \item{\code{fourth_downs}}{integer.} -#' \item{\code{fourth_conv_rate}}{double.} -#' \item{\code{penalties}}{integer.} -#' \item{\code{penalty_yds}}{integer.} -#' \item{\code{penalties_pg}}{double.} -#' \item{\code{penalty_yds_pg}}{double.} -#' \item{\code{yards_per_penalty}}{double.} -#' \item{\code{kick_returns}}{integer.} -#' \item{\code{kick_return_yds}}{integer.} -#' \item{\code{kick_return_TDs}}{integer.} -#' \item{\code{kick_return_avg}}{double.} -#' \item{\code{punt_returns}}{integer.} -#' \item{\code{punt_return_yds}}{integer.} -#' \item{\code{punt_return_TDs}}{integer.} -#' \item{\code{punt_return_avg}}{double.} -#' \item{\code{passes_intercepted}}{integer.} -#' \item{\code{passes_intercepted_yds}}{integer.} -#' \item{\code{passes_intercepted_TDs}}{integer.} +#' \item{`games`: integer.}{.} +#' \item{`team`: character.}{.} +#' \item{`conference`: character.}{.} +#' \item{`games`: integer.}{.} +#' \item{`time_of_poss_total`: integer.}{.} +#' \item{`time_of_poss_pg`: double.}{.} +#' \item{`pass_comps`: integer.}{.} +#' \item{`pass_atts`: integer.}{.} +#' \item{`completion_pct`: double.}{.} +#' \item{`net_pass_yds`: integer.}{.} +#' \item{`pass_ypa`: double.}{.} +#' \item{`pass_ypr`: double.}{.} +#' \item{`pass_TDs`: integer.}{.} +#' \item{`interceptions`: integer.}{.} +#' \item{`int_pct`: double.}{.} +#' \item{`rush_atts`: integer.}{.} +#' \item{`rush_yds`: integer.}{.} +#' \item{`rush_TDs`: integer.}{.} +#' \item{`rush_ypc`: double.}{.} +#' \item{`total_yds`: integer.}{.} +#' \item{`fumbles_lost`: integer.}{.} +#' \item{`turnovers`: integer.}{.} +#' \item{`turnovers_pg`: double.}{.} +#' \item{`first_downs`: integer.}{.} +#' \item{`third_downs`: integer.}{.} +#' \item{`third_down_convs`: integer.}{.} +#' \item{`third_conv_rate`: double.}{.} +#' \item{`fourth_down_convs`: integer.}{.} +#' \item{`fourth_downs`: integer.}{.} +#' \item{`fourth_conv_rate`: double.}{.} +#' \item{`penalties`: integer.}{.} +#' \item{`penalty_yds`: integer.}{.} +#' \item{`penalties_pg`: double.}{.} +#' \item{`penalty_yds_pg`: double.}{.} +#' \item{`yards_per_penalty`: double.}{.} +#' \item{`kick_returns`: integer.}{.} +#' \item{`kick_return_yds`: integer.}{.} +#' \item{`kick_return_TDs`: integer.}{.} +#' \item{`kick_return_avg`: double.}{.} +#' \item{`punt_returns`: integer.}{.} +#' \item{`punt_return_yds`: integer.}{.} +#' \item{`punt_return_TDs`: integer.}{.} +#' \item{`punt_return_avg`: double.}{.} +#' \item{`passes_intercepted`: integer.}{.} +#' \item{`passes_intercepted_yds`: integer.}{.} +#' \item{`passes_intercepted_TDs`: integer.}{.} #' } #' @source \url{https://api.collegefootballdata.com/stats/season} #' @keywords Team Season Stats diff --git a/R/cfbd_teams.R b/R/cfbd_teams.R index 2037a146..fe7a292b 100644 --- a/R/cfbd_teams.R +++ b/R/cfbd_teams.R @@ -1,11 +1,17 @@ -#' CFBD Teams Endpoint #' @name cfbd_teams -NULL -#' Team Info Lookup -#' Lists all teams in conference or all D-I teams if conference is left NULL -#' Current support only for D-I -#' -#' @rdname cfbd_teams +#' @aliases cfbd_team_info cfbd_team_matchup_records cfbd_team_matchup cfbd_team_roster cfbd_team_talent +#' @title CFBD Teams Endpoint +#' @description +#' \describe{ +#' \item{`cfbd_team_info()`: Team Info Lookup}{.} +#' \item{`cfbd_team_matchup_records()`: Get matchup history records between two teams.}{.} +#' \item{`cfbd_team_matchup()`: Get matchup history between two teams.}{.} +#' \item{`cfbd_team_roster()`: Get a team's full roster by year.}{.} +#' \item{`cfbd_team_talent()`: Get composite team talent rankings for all teams in a given year}{.} +#' } +#' ## Team Info Lookup +#' Lists all teams in conference or all D-I teams if conference is left NULL +#' Currently, support is only provided for D-I #' @param conference (\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr #' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC,\cr #' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC\cr @@ -13,36 +19,34 @@ NULL #' If year is left blank while only_fbs is TRUE, then will return values for most current year #' @param year (\emph{Integer} optional): Year, 4 digit format (\emph{YYYY}). Filter for getting a list of major division team for a given year #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' -#' @return \code{\link[cfbfastR:cfbd_team_info]{cfbfastR::cfbd_team_info()}} - A data frame with 12 variables: +#' @return [cfbd_team_info()] - A data frame with 12 variables: #' \describe{ -#' \item{\code{team_id}}{integer.} -#' \item{\code{school}}{character.} -#' \item{\code{mascot}}{character.} -#' \item{\code{abbreviation}}{character.} -#' \item{\code{alt_name1}}{character.} -#' \item{\code{alt_name2}}{character.} -#' \item{\code{alt_name3}}{character.} -#' \item{\code{conference}}{character.} -#' \item{\code{division}}{character.} -#' \item{\code{color}}{character.} -#' \item{\code{alt_color}}{character.} -#' \item{\code{logo_1}}{character.} -#' \item{\code{logo_2}}{character.} -#' \item{\code{venue_id}}{character.} -#' \item{\code{venue_name}}{character.} -#' \item{\code{city}}{character.} -#' \item{\code{state}}{character.} -#' \item{\code{zip}}{character.} -#' \item{\code{country_code}}{character.} -#' \item{\code{timezone}}{character.} -#' \item{\code{latitude}}{character.} -#' \item{\code{longitude}}{character.} -#' \item{\code{elevation}}{character.} -#' \item{\code{capacity}}{character.} -#' \item{\code{year_constructed}}{character.} -#' \item{\code{grass}}{character.} -#' \item{\code{dome}}{character.} +#' \item{`team_id`: integer.}{Referencing team id.} +#' \item{`school`: character.}{Team name.} +#' \item{`mascot`: character.}{Team mascot.} +#' \item{`abbreviation`: character.}{Team abbreviations.} +#' \item{`alt_name1`: character.}{Team alternate name 1 (as it appears in `play_text`).} +#' \item{`alt_name2`: character.}{Team alternate name 2 (as it appears in `play_text`).} +#' \item{`alt_name3`: character.}{Team alternate name 3 (as it appears in `play_text`).} +#' \item{`conference`: character.}{Conference of team.} +#' \item{`division`: character.}{Division of team within the conference.} +#' \item{`color`: character.}{Team color (primary).} +#' \item{`alt_color`: character.}{Team color (alternate).} +#' \item{`logos`: character.}{Team logos.} +#' \item{`venue_id`: character.}{Referencing venue id.} +#' \item{`venue_name`: character.}{Stadium name.} +#' \item{`city`: character.}{Team/venue city.} +#' \item{`state`: character.}{Team/venue state.} +#' \item{`zip`: character.}{Team/venue zip code (someone double check Miami (FL) on if they're in the same zip code).} +#' \item{`country_code`: character.}{Team/venue country code.} +#' \item{`timezone`: character.}{Team/venue timezone.} +#' \item{`latitude`: character.}{Venue latitude.} +#' \item{`longitude`: character.}{Venue longitude.} +#' \item{`elevation`: character.}{Venue elevation.} +#' \item{`capacity`: character.}{Venue capacity.} +#' \item{`year_constructed`: character.}{Year the venue was constructed.} +#' \item{`grass`: character.}{TRUE/FALSE response on whether the field is grass or not (oh, and there are so many others).} +#' \item{`dome`: character.}{TRUE/FALSE flag for if the venue is a domed stadium.} #' } #' @source \url{https://api.collegefootballdata.com/teams} #' @keywords Teams @@ -60,7 +64,6 @@ NULL #' #' cfbd_team_info(year = 2019) #' } -#' cfbd_team_info <- function(conference = NULL, only_fbs = TRUE, year = NULL, verbose = FALSE) { if (!is.null(conference)) { @@ -178,24 +181,23 @@ cfbd_team_info <- function(conference = NULL, only_fbs = TRUE, year = NULL, } -#' Get matchup history records between two teams. #' @rdname cfbd_teams -#' +#' @title Get matchup history records between two teams. #' @param team1 (\emph{String} required): D-I Team 1 #' @param team2 (\emph{String} required): D-I Team 2 #' @param min_year (\emph{Integer} optional): Minimum of year range, 4 digit format (\emph{YYYY}) #' @param max_year (\emph{Integer} optional): Maximum of year range, 4 digit format (\emph{YYYY}) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_team_matchup_records]{cfbfastR::cfbd_team_matchup_records()}} - A data frame with 7 variables: +#' @return [cfbd_team_matchup_records()] - A data frame with 7 variables: #' \describe{ -#' \item{\code{start_year}}{character.} -#' \item{\code{end_year}}{character.} -#' \item{\code{team1}}{character.} -#' \item{\code{team1_wins}}{character.} -#' \item{\code{team2}}{character.} -#' \item{\code{team2_wins}}{character.} -#' \item{\code{ties}}{character.} +#' \item{`start_year`: character.}{Span starting year.} +#' \item{`end_year`: character.}{Span ending year.} +#' \item{`team1`: character.}{First team selected in query.} +#' \item{`team1_wins`: character.}{First team wins in series against `team2`.} +#' \item{`team2`: character.}{Second team selected in query.} +#' \item{`team2_wins`: character.}{Second team wins in series against `team1`.} +#' \item{`ties`: character.}{Number of ties in the series.} #' } #' @source \url{https://api.collegefootballdata.com/teams/matchup} #' @keywords Team Matchup Records @@ -312,28 +314,26 @@ cfbd_team_matchup_records <- function(team1, team2, min_year = NULL, max_year = } -#' Get matchup history between two teams. #' @rdname cfbd_teams -#' +#' @title Get matchup history between two teams. #' @param team1 (\emph{String} required): D-I Team 1 #' @param team2 (\emph{String} required): D-I Team 2 #' @param min_year (\emph{Integer} optional): Minimum of year range, 4 digit format (\emph{YYYY}) #' @param max_year (\emph{Integer} optional): Maximum of year range, 4 digit format (\emph{YYYY}) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function -#' -#' @return \code{\link[cfbfastR:cfbd_team_matchup]{cfbfastR::cfbd_team_matchup()}} - A data frame with 11 variables: +#' @return [cfbd_team_matchup] - A data frame with 11 variables: #' \describe{ -#' \item{\code{season}}{integer.} -#' \item{\code{week}}{integer.} -#' \item{\code{season_type}}{character.} -#' \item{\code{date}}{character.} -#' \item{\code{neutral_site}}{logical.} -#' \item{\code{venue}}{character.} -#' \item{\code{home_team}}{character.} -#' \item{\code{home_score}}{integer.} -#' \item{\code{away_team}}{character.} -#' \item{\code{away_score}}{integer.} -#' \item{\code{winner}}{character.} +#' \item{`season`: integer.}{Season the game took place.} +#' \item{`week`: integer.}{Game week of the season.} +#' \item{`season_type`: character.}{Season type of the game.} +#' \item{`date`: character.}{Game date.} +#' \item{`neutral_site`: logical.}{TRUE/FALSE flag for if the game took place at a neutral site.} +#' \item{`venue`: character.}{Stadium name.} +#' \item{`home_team`: character.}{Home team of the game.} +#' \item{`home_score`: integer.}{Home score in the game.} +#' \item{`away_team`: character.}{Away team of the game.} +#' \item{`away_score`: integer.}{Away score in the game.} +#' \item{`winner`: character.}{Winner of the matchup.} #' } #' @source \url{https://api.collegefootballdata.com/teams/matchup} #' @keywords Team Matchup @@ -443,32 +443,31 @@ cfbd_team_matchup <- function(team1, team2, min_year = NULL, max_year = NULL, } -#' Team Roster +#' @rdname cfbd_teams +#' @title Team Roster #' Get a teams full roster by year. If team is not selected, API returns rosters for every team from the selected year. #' -#' @rdname cfbd_teams #' @param year (\emph{Integer} required): Year, 4 digit format (\emph{YYYY}) #' @param team (\emph{String} optional): Team, select a valid team in D-I football #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' -#' @return \code{\link[cfbfastR:cfbd_team_roster]{cfbfastR::cfbd_team_roster()}} - A data frame with 12 variables: +#' @return [cfbd_team_roster()] - A data frame with 12 variables: #' \describe{ -#' \item{\code{athlete_id}}{character.} -#' \item{\code{first_name}}{character.} -#' \item{\code{last_name}}{character.} -#' \item{\code{team}}{character.} -#' \item{\code{weight}}{integer.} -#' \item{\code{height}}{integer.} -#' \item{\code{jersey}}{integer.} -#' \item{\code{year}}{integer.} -#' \item{\code{position}}{character.} -#' \item{\code{home_city}}{character.} -#' \item{\code{home_state}}{character.} -#' \item{\code{home_country}}{character.} -#' \item{\code{home_latitude}}{numeric.} -#' \item{\code{home_longitude}}{number.} -#' \item{\code{home_county_fips}}{integer.} +#' \item{`athlete_id`: character.}{Referencing athlete id.} +#' \item{`first_name`: character.}{Athlete first name.} +#' \item{`last_name`: character.}{Athlete last name.} +#' \item{`team`: character.}{Team name.} +#' \item{`weight`: integer.}{Athlete weight.} +#' \item{`height`: integer.}{Athlete height.} +#' \item{`jersey`: integer.}{Athlete jersey number.} +#' \item{`year`: integer.}{Athlete year.} +#' \item{`position`: character.}{Athlete position.} +#' \item{`home_city`: character.}{Hometown of the athlete.} +#' \item{`home_state`: character.}{Hometown state of the athlete.} +#' \item{`home_country`: character.}{Hometown country of the athlete.} +#' \item{`home_latitude`: numeric.}{Hometown latitude.} +#' \item{`home_longitude`: number.}{Hometown longitude.} +#' \item{`home_county_fips`: integer.}{Hometown FIPS code.} #' } #' @source \url{https://api.collegefootballdata.com/roster} #' @keywords Team Roster @@ -563,11 +562,11 @@ cfbd_team_roster <- function(year, team = NULL, #' @param year (\emph{Integer} optional): Year 4 digit format (\emph{YYYY}) #' @param verbose Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function #' -#' @return \code{\link[cfbfastR:cfbd_team_talent]{cfbfastR::cfbd_team_talent()}} - A data frame with 3 variables: +#' @return [cfbd_team_talent()] - A data frame with 3 variables: #' \describe{ -#' \item{\code{year}}{integer.} -#' \item{\code{school}}{character.} -#' \item{\code{talent}}{double.} +#' \item{`year`: integer.}{Season for the talent rating.} +#' \item{`school`: character.}{Team name.} +#' \item{`talent`: double.}{Overall roster talent points (as determined by 247Sports).} #' } #' @source \url{https://api.collegefootballdata.com/talent} #' @keywords Team talent diff --git a/R/cfbd_venues.R b/R/cfbd_venues.R index dfaf9664..c0b5f154 100644 --- a/R/cfbd_venues.R +++ b/R/cfbd_venues.R @@ -1,35 +1,37 @@ -#' CFB Venue Information -#' -#' Pulls all college football venues and data on capacity, grass, city/state, location, -#' elevation, dome, timezone and construction year -#' -#' @return A data frame with 335 rows and 13 variables: +#' @title CFBD Venues Endpoint +#' @description Pulls all college football venues and data on capacity, grass, city/state, location, +#' elevation, dome, timezone and construction year. +#' @details CFB Venue Information +#' ```r +#' cfbd_venues() +#' ``` +#' @return A data frame with 337 rows and 13 variables: #' \describe{ -#' \item{\code{venue_id}}{integer.} -#' \item{\code{name}}{character.} -#' \item{\code{capacity}}{integer.} -#' \item{\code{grass}}{logical.} -#' \item{\code{city}}{character.} -#' \item{\code{state}}{character.} -#' \item{\code{zip}}{character.} -#' \item{\code{country_code}}{character.} -#' \item{\code{location}}{list.} -#' \item{\code{elevation}}{character.} -#' \item{\code{year_constructed}}{integer.} -#' \item{\code{dome}}{logical.} -#' \item{\code{timezone}}{character.} +#' \item{`venue_id`:integer.}{Referencing venue ID.} +#' \item{`name`:character.}{Venue name.} +#' \item{`capacity`:integer.}{Stadium capacity.} +#' \item{`grass`:logical.}{TRUE/FALSE response on whether the field is grass or not (oh, and there are so many others).} +#' \item{`city`:character.}{Venue city.} +#' \item{`state`:character.}{Venue state.} +#' \item{`zip`:character.}{Venue zip.} +#' \item{`country_code`:character.}{Venue country code.} +#' \item{`location`:list.}{Venue location.} +#' \item{`elevation`:character.}{Venue elevation.} +#' \item{`year_constructed`:integer.}{Year in which the venue was constructed.} +#' \item{`dome`:logical.}{TRUE/FALSE response to whether the venue has a dome or not.} +#' \item{`timezone`:character.}{Time zone in which the venue resides (i.e. Eastern Time -> "America/New York").} #' } #' @source \url{https://api.collegefootballdata.com/venues} #' @keywords Venues #' @importFrom jsonlite fromJSON #' @importFrom httr GET #' @importFrom dplyr rename -#' @export #' @examples #' \donttest{ -#' cfbd_venues() +#' cfbd_venues() #' } -#' +#' @export + cfbd_venues <- function() { full_url <- "https://api.collegefootballdata.com/venues" diff --git a/R/create_epa.R b/R/create_epa.R index 2d3bd476..dcfc6cab 100644 --- a/R/create_epa.R +++ b/R/create_epa.R @@ -1,17 +1,19 @@ -#' Create EPA -#' Adds Expected Points calculations to Play-by-Play data.frame +#' @name create_epa +#' @aliases create_epa epa_fg_probs +#' @title Create EPA +#' @description Adds Expected Points calculations to Play-by-Play data.frame #' -#' @param clean_pbp_dat (\emph{data.frame} required): Clean PBP as input from \code{\link[cfbfastR:cfbd_pbp_data]{cfbfastR::cfbd_pbp_data()}}) -#' @param ep_model (\emph{model} default cfbfastR:::ep_model): Expected Points (EP) Model -#' @param fg_model (\emph{model} default cfbfastR:::fg_model): Field Goal (FG) Model +#' @param clean_pbp_dat (\emph{data.frame} required): Clean PBP as input from [cfbd_pbp_data()] +#' @param ep_model (\emph{model} default ```cfbfastR```'s `ep_model`): Expected Points (EP) Model +#' @param fg_model (\emph{model} default ```cfbfastR```'s `fg_model`): Field Goal (FG) Model #' @details Code Description #' \describe{ -#' \item{1. \code{pred_df}}{Use select before play model variables -> Make predictions.} -#' \item{2. \code{epa_fg_probs}}{Update expected points predictions from before variables with FG make/miss probability weighted adjustment.} -#' \item{3. \code{pred_df_after}}{Use select after play model variables -> Make predictions .} -#' \item{4. \code{join_ep}}{Join `ep_before` calcs `pred_df` with ep_after calcs `pred_df_after` on c("game_id","drive_id","new_id").} -#' \item{5. \code{kickoffs}}{Calculate ep_before for kickoffs as if the pre-play assumption is a touchback.} -#' \item{6. \code{wpa_prep}}{Prep variables for WPA.} +#' \item{1. `pred_df`:}{Use select before play model variables -> Make predictions.} +#' \item{2. `epa_fg_probs`:}{Update expected points predictions from before variables with FG make/miss probability weighted adjustment.} +#' \item{3. `pred_df_after`:}{Use select after play model variables -> Make predictions.} +#' \item{4. `join_ep`:}{Join `ep_before` calcs `pred_df` with `ep_after` calcs `pred_df_after` on c("game_id","drive_id","new_id").} +#' \item{5. `kickoffs`:}{Calculate ep_before for kickoffs as if the pre-play assumption is a touchback.} +#' \item{6. `wpa_prep`:}{Prep variables for WPA.} #' } #' @keywords internal #' @importFrom stats na.omit @@ -456,22 +458,17 @@ create_epa <- function(play_df, return(pred_df) } -#' Performs Field Goal adjustments for Expected Points model calculations -#' -#' Extracts raw game by game data. -#' -#' @param df (\emph{data.frame} required): Clean Play-By-Play data.frame as can be pulled from `cfbd_pbp_dat()` -#' @param current_probs (\emph{data.frame} required): Expected Points (EP) model raw probability outputs from initial prediction -#' @param ep_model (\emph{model}, default `cfbfastR:::ep_model`): FG Model to be used for prediction on field goal (FG) attempts in Play-by-Play data.frame -#' @param fg_mod (\emph{model}, default `cfbfastR:::fg_model`): FG Model to be used for prediction on field goal (FG) attempts in Play-by-Play data.frame +#' @rdname create_epa +#' @param df (__data.frame__ required): Clean Play-By-Play data.frame as can be pulled from [clean_pbp_dat()] +#' @param current_probs (__data.frame__ required): Expected Points (EP) model raw probability outputs from initial prediction +#' @param ep_model (__model__, default ```cfbfastR```'s `ep_model`): FG Model to be used for prediction on field goal (FG) attempts in Play-by-Play data.frame +#' @param fg_mod (__model__, default ```cfbfastR```'s `fg_model`): FG Model to be used for prediction on field goal (FG) attempts in Play-by-Play data.frame #' #' @keywords internal #' @importFrom mgcv predict.bam #' @importFrom stringr str_detect #' @importFrom dplyr mutate #' @export -#' -#' epa_fg_probs <- function(dat, current_probs, ep_model, fg_mod) { fg_ind <- stringr::str_detect((dat$play_type), "Field Goal") diff --git a/R/create_wpa_naive.R b/R/create_wpa_naive.R index 8552a725..1cfa800a 100644 --- a/R/create_wpa_naive.R +++ b/R/create_wpa_naive.R @@ -1,7 +1,7 @@ -#' Add Win Probability Added (WPA) calculations to Play-by-Play DataFrame -#' This is only for D1 football -#' -#' Extracts raw game by game data. +#' @name create_wpa +#' @aliases create_wpa_naive wpa_calcs_naive +#' @title Add Win Probability Added (WPA) calculations to Play-by-Play DataFrame +#' @description This is only for D1 football #' @param df (\emph{data.frame} required): Clean Play-by-Play data.frame with Expected Points Added (EPA) calculations #' @param wp_model (\emph{model} default cfbfastR:wp_model): Win Probability (WP) Model #' @details Requires the following columns to be present in the input data frame. @@ -142,9 +142,8 @@ create_wpa_naive <- function(df, wp_model) { return(df2) } -#' WPA Calcs -#' -#' Extracts raw game by game data. + +#' @rdname create_wpa #' @param df (\emph{data.frame} required): Clean Play-by-Play data.frame with Expected Points Added (EPA) calculations #' @keywords internal #' @importFrom dplyr mutate lead if_else diff --git a/R/espn_metrics_wp.R b/R/espn_metrics_wp.R index 0eb64d7d..3840d472 100644 --- a/R/espn_metrics_wp.R +++ b/R/espn_metrics_wp.R @@ -7,15 +7,16 @@ NULL #' @rdname espn_metrics #' #' @param game_id (\emph{Integer} required): Game ID filter for querying a single game\cr -#' Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function +#' Can be found using the [cfbd_game_info()] function #' -#' @return espn_metrics_wp - A data frame with 5 variables: +#' @return [espn_metrics_wp()] - A data frame with 5 variables: #' \describe{ -#' \item{\code{espn_game_id}}{character.} -#' \item{\code{play_id}}{character.} -#' \item{\code{seconds_left}}{integer.} -#' \item{\code{home_win_percentage}}{double.} -#' \item{\code{away_win_percentage}}{double.} +#' \item{`game_id`: character.}{Referencing game ID (should be same as `game_id` from other functions).} +#' \item{`play_id`: character.}{Referencing play ID.} +#' \item{`seconds_left`: integer.}{Seconds left in the game.} +#' \item{`home_win_percentage`: double.}{The probability of the home team winning the game.} +#' \item{`away_win_percentage`: double.}{The probability of the away team winning the game (calculated as 1 - `home_win_percentage` - `tie_percentage`).} +#' \item{`tie_percentage`: double.}{The probability of the game ending the final period in a tie.} #' } #' @keywords Win Probability Chart Data #' @importFrom jsonlite fromJSON @@ -58,14 +59,15 @@ espn_metrics_wp <- function(game_id) { dplyr::rename( home_win_percentage = .data$home_win_percentage, seconds_left = .data$seconds_left, - play_id = .data$play_id + play_id = .data$play_id, + game_id = .data$espn_game_id ) %>% dplyr::mutate( - away_win_percentage = 1 - .data$home_win_percentage + away_win_percentage = 1 - .data$home_win_percentage - .data$tie_percentage ) %>% dplyr::select( - .data$espn_game_id, .data$play_id, .data$seconds_left, - .data$home_win_percentage, .data$away_win_percentage + .data$game_id, .data$play_id, .data$seconds_left, + .data$home_win_percentage, .data$away_win_percentage, .data$tie_percentage ) message(glue::glue("{Sys.time()}: Scraping ESPN win probability data for game_id '{espn_game_id}'...")) }, diff --git a/R/espn_ratings_fpi.R b/R/espn_ratings_fpi.R index a80640bb..b93f7e39 100644 --- a/R/espn_ratings_fpi.R +++ b/R/espn_ratings_fpi.R @@ -1,33 +1,31 @@ -#' ESPN Ratings #' @name espn_ratings -NULL -#' Get FPI historical rating data (most recent of each year) -#' Adapted from sabinanalytic's fork of the cfbfastR repo -#' @rdname espn_ratings +#' @aliases espn_ratings_fpi +#' @title ESPN FPI Ratings +#' @description Get FPI historical rating data (most recent of each year) +#' @details Adapted from sabinanalytic's fork of the cfbfastR repo #' @source \url{https://github.com/sabinanalytics/cfbfastR/blob/master/R/cfbd_ratings_fpi.R} #' @param year Year #' @return A data frame with 20 variables: #' \describe{ -#' \item{\code{year}}{double.} -#' \item{\code{id}}{character.} -#' \item{\code{name}}{character.} -#' \item{\code{abbr}}{character.} -#' \item{\code{row_n}}{integer.} -#' \item{\code{fpi}}{character.} -#' \item{\code{fpi_rk}}{character.} -#' \item{\code{trend}}{character.} -#' \item{\code{proj_w}}{character.} -#' \item{\code{proj_l}}{character.} -#' \item{\code{win_out}}{double.} -#' \item{\code{win_6}}{double.} -#' \item{\code{win_div}}{double.} -#' \item{\code{playoff}}{double.} -#' \item{\code{nc_game}}{double.} -#' \item{\code{nc_win}}{double.} -#' \item{\code{win_conf}}{double.} -#' \item{\code{w}}{character.} -#' \item{\code{l}}{character.} -#' \item{\code{t}}{character.} +#' \item{`year`: double.}{Season of the Football Power Index (FPI) Rating.} +#' \item{`team_id`: character.}{Unique ESPN team ID - `team_id`.} +#' \item{`name`: character.}{Team Name.} +#' \item{`abbr`: character.}{Team abbreviation.} +#' \item{`fpi`: character.}{Football Power Index (FPI) Rating.} +#' \item{`fpi_rk`: character.}{Football Power Index (FPI) Rank.} +#' \item{`trend`: character.}{Football Power Index (FPI) ranking trend.} +#' \item{`proj_w`: character.}{Projected Win total for the season.} +#' \item{`proj_l`: character.}{Projected Loss total for the season.} +#' \item{`win_out`: double.}{Probability the team wins out.} +#' \item{`win_6`: double.}{Probability the team wins at least six games.} +#' \item{`win_div`: double.}{Probability the team wins at their division.} +#' \item{`playoff`: double.}{Probability the team reaches the playoff.} +#' \item{`nc_game`: double.}{Probability the team reaches the national championship game.} +#' \item{`nc_win`: double.}{Probability the team wins the national championship game.} +#' \item{`win_conf`: double.}{Probability the team wins their conference game.} +#' \item{`w`: character.}{Wins on the season.} +#' \item{`l`: character.}{Losses on the season.} +#' \item{`t`: character.}{Ties on the season.} #' } #' @keywords Ratings FPI #' @importFrom stringr str_remove @@ -41,7 +39,6 @@ NULL #' @importFrom glue glue #' @export #' @examples -#' #' espn_ratings_fpi(year = 2018) espn_ratings_fpi <- function(year = 2019) { current_year <- as.double(substr(Sys.Date(), 1, 4)) @@ -90,7 +87,9 @@ espn_ratings_fpi <- function(year = 2019) { dplyr::select(-c("logos", "links")) %>% dplyr::mutate(year = year, t = ifelse(is.na(t), 0, t)) %>% dplyr::mutate_at(vars(.data$win_out:.data$win_conf), ~ as.double(stringr::str_remove(., "%")) / 100) %>% - dplyr::select(.data$year, tidyr::everything()) %>% + dplyr::select(.data$year, tidyr::everything()) %>% + dplyr::select(-.data$row_n) %>% + dplyr::rename(team_id = .data$id) %>% as.data.frame() return(df) diff --git a/R/helper_pbp_add_player_cols.R b/R/helper_pbp_add_player_cols.R index 099be3b8..731df0ba 100644 --- a/R/helper_pbp_add_player_cols.R +++ b/R/helper_pbp_add_player_cols.R @@ -1,36 +1,35 @@ -#' Add player columns extracted from play text -#' +#' @rdname helpers_pbp #' @param play_df (\emph{data.frame} required) Extracts player name information from Play-by-Play data frame, as pulled from `cfbd_pbp_data()` #' @details Cleans CFB (D-I) player Data to create player name columns. Requires the following columns be present: #' \itemize{ -#' \item{rush}{.} -#' \item{pass}{.} -#' \item{play_text}{} -#' \item{play_type}{.} -#' \item{sack}{.} -#' \item{fumble_vec}{.} +#' \item{`rush`}{.} +#' \item{`pass`}{.} +#' \item{`play_text`}{.} +#' \item{`play_type`}{.} +#' \item{`sack`}{.} +#' \item{`fumble_vec`}{.} #' } #' @return The original `pbp` with the following columns appended to it: #' \describe{ -#' \item{rusher_player_name}{.} -#' \item{receiver_player_name}{.} -#' \item{passer_player_name}{.} -#' \item{sack_player_name}{.} -#' \item{sack_player_name2}{.} -#' \item{pass_breakup_player_name}{.} -#' \item{interception_player_name}{.} -#' \item{fg_kicker_player_name}{.} -#' \item{fg_block_player_name}{.} -#' \item{fg_return_player_name}{.} -#' \item{kickoff_player_name}{.} -#' \item{kickoff_returner_player_name}{.} -#' \item{punter_player_name}{.} -#' \item{punt_block_player_name}{.} -#' \item{punt_returner_player_name}{.} -#' \item{punt_block_return_player_name}{.} -#' \item{fumble_player_name}{.} -#' \item{fumble_forced_player_name}{.} -#' \item{fumble_recovered_player_name}{.} +#' \item{`rusher_player_name`}{.} +#' \item{`receiver_player_name`}{.} +#' \item{`passer_player_name`}{.} +#' \item{`sack_player_name`}{.} +#' \item{`sack_player_name2`}{.} +#' \item{`pass_breakup_player_name`}{.} +#' \item{`interception_player_name`}{.} +#' \item{`fg_kicker_player_name`}{.} +#' \item{`fg_block_player_name`}{.} +#' \item{`fg_return_player_name`}{.} +#' \item{`kickoff_player_name`}{.} +#' \item{`kickoff_returner_player_name`}{.} +#' \item{`punter_player_name`}{.} +#' \item{`punt_block_player_name`}{.} +#' \item{`punt_returner_player_name`}{.} +#' \item{`punt_block_return_player_name`}{.} +#' \item{`fumble_player_name`}{.} +#' \item{`fumble_forced_player_name`}{.} +#' \item{`fumble_recovered_player_name`}{.} #' } #' @keywords internal #' @importFrom rlang .data diff --git a/R/helper_pbp_add_yardage.R b/R/helper_pbp_add_yardage.R index 82fe9728..79027f5a 100644 --- a/R/helper_pbp_add_yardage.R +++ b/R/helper_pbp_add_yardage.R @@ -1,39 +1,38 @@ -#' Add yardage extracted from play text -#' +#' @rdname helpers_pbp #' @param play_df (\emph{data.frame} required) Extracts yardage information from Play-by-Play data frame, as pulled from `cfbd_pbp_data()` #' @details Cleans CFB (D-I) Drive-By-Drive Data to create yardage column. Requires the following columns be present: #' \describe{ -#' \item{play_text}{.} -#' \item{play_type}{.} -#' \item{rush}{.} -#' \item{pass}{.} -#' \item{int}{.} -#' \item{int_td}{.} -#' \item{kickoff_play}{.} -#' \item{kickoff_tb}{.} -#' \item{kickoff_downed}{.} -#' \item{kickoff_fair_catch}{.} -#' \item{fumble_vec}{.} -#' \item{sack}{.} -#' \item{punt}{.} -#' \item{punt_tb}{.} -#' \item{punt_downed}{.} -#' \item{punt_fair_catch}{.} -#' \item{punt_oob}{.} -#' \item{punt_blocked}{.} -#' \item{penalty_detail}{.} +#' \item{`play_text`}{.} +#' \item{`play_type`}{.} +#' \item{`rush`}{.} +#' \item{`pass`}{.} +#' \item{`int`}{.} +#' \item{`int_td`}{.} +#' \item{`kickoff_play`}{.} +#' \item{`kickoff_tb`}{.} +#' \item{`kickoff_downed`}{.} +#' \item{`kickoff_fair_catch`}{.} +#' \item{`fumble_vec`}{.} +#' \item{`sack`}{.} +#' \item{`punt`}{.} +#' \item{`punt_tb`}{.} +#' \item{`punt_downed`}{.} +#' \item{`punt_fair_catch`}{.} +#' \item{`punt_oob`}{.} +#' \item{`punt_blocked`}{.} +#' \item{`penalty_detail`}{.} #' } #' @return The original `play_df` with the following columns appended to it: #' \describe{ -#' \item{yds_rushed}{.} -#' \item{yds_receiving}{.} -#' \item{yds_int_return}{.} -#' \item{yds_kickoff}{.} -#' \item{yds_kickoff_return}{.} -#' \item{yds_punted}{.} -#' \item{yds_fumble_return}{.} -#' \item{yds_sacked}{.} -#' \item{yds_penalty}{.} +#' \item{`yds_rushed`}{.} +#' \item{`yds_receiving`}{.} +#' \item{`yds_int_return`}{.} +#' \item{`yds_kickoff`}{.} +#' \item{`yds_kickoff_return`}{.} +#' \item{`yds_punted`}{.} +#' \item{`yds_fumble_return`}{.} +#' \item{`yds_sacked`}{.} +#' \item{`yds_penalty`}{.} #' } #' @keywords internal #' @importFrom rlang .data diff --git a/R/helper_pbp_clean_pbp_dat.R b/R/helper_pbp_clean_pbp_dat.R index f0bf8fb2..93225842 100644 --- a/R/helper_pbp_clean_pbp_dat.R +++ b/R/helper_pbp_clean_pbp_dat.R @@ -1,6 +1,4 @@ -#' Clean Play-by-Play data -#' Cleans Play-by-Play data pulled from the API's raw game data -#' +#' @rdname helpers_pbp #' @param play_df (\emph{data.frame} required): Performs data cleansing on Play-by-Play DataFrame, as pulled from `cfbd_pbp_data()` #' @details Requires the following columns to be present #' \describe{ diff --git a/R/helper_pbp_penalty_detection.R b/R/helper_pbp_penalty_detection.R index 8d9da0b5..52ecfc9e 100644 --- a/R/helper_pbp_penalty_detection.R +++ b/R/helper_pbp_penalty_detection.R @@ -1,27 +1,26 @@ -#' Penalty Detection -#' Adds penalty columns to Play-by-Play data pulled from the API +#' @rdname helpers_pbp #' #' @param raw_df (\emph{data.frame} required): Performs data cleansing on Play-by-Play DataFrame, as pulled from `cfbd_pbp_data()` #' @details Runs penalty detection on the play text and play types. Requires the following columns be present: #' \itemize{ -#' \item{game_id} -#' \item{period} -#' \item{down} -#' \item{play_type} -#' \item{play_text} +#' \item{`game_id`}{Referencing game id.} +#' \item{`period`}{Game period (quarter).} +#' \item{`down`}{Down of the play.} +#' \item{`play_type`}{Categorical play type.} +#' \item{`play_text`}{A description of the play.} #' } #' @return The original `raw_df` with the following columns appended/redefined: #' \describe{ -#' \item{penalty_flag}{TRUE/FALSE flag for penalty play types or penalty in play text plays.} -#' \item{penalty_declined}{TRUE/FALSE flag for 'declined' in penalty play types or penalty in play text plays.} -#' \item{penalty_no_play}{TRUE/FALSE flag for 'no play' in penalty play types or penalty in play text plays.} -#' \item{penalty_offset}{TRUE/FALSE flag for 'off-setting' in penalty play types or penalty in play text plays.} -#' \item{penalty_1st_conv}{TRUE/FALSE flag for 1st Down in penalty play types or penalty in play text plays.} -#' \item{penalty_text}{TRUE/FALSE flag for penalty in text but not a penalty play type.} -#' \item{orig_play_type}{Copy of original play_type label prior to any changes by the proceeding functions} -#' \item{down}{Defines kickoff downs and penalties on kickoffs and converts them from 5 (as from the API) to 1.} -#' \item{play_type}{Defines `play_type`, "Penalty (Kickoff)", penalties on kickoffs with a repeat kick.} -#' \item{half}{Defines the half variable (1, 2).} +#' \item{`penalty_flag`: TRUE/FALSE flag for penalty play types or penalty in play text plays.}{.} +#' \item{`penalty_declined`: TRUE/FALSE flag for 'declined' in penalty play types or penalty in play text plays.}{.} +#' \item{`penalty_no_play`: TRUE/FALSE flag for 'no play' in penalty play types or penalty in play text plays.}{.} +#' \item{`penalty_offset`: TRUE/FALSE flag for 'off-setting' in penalty play types or penalty in play text plays.}{.} +#' \item{`penalty_1st_conv`: TRUE/FALSE flag for 1st Down in penalty play types or penalty in play text plays.}{.} +#' \item{`penalty_text`: TRUE/FALSE flag for penalty in text but not a penalty play type.}{.} +#' \item{`orig_play_type`: Copy of original play_type label prior to any changes by the proceeding functions}{.} +#' \item{`down`: Defines kickoff downs and penalties on kickoffs and converts them from 5 (as from the API) to 1.}{.} +#' \item{`play_type`: Defines `play_type`, "Penalty (Kickoff)", penalties on kickoffs with a repeat kick.}{.} +#' \item{`half`: Defines the half variable (1, 2).}{.} #' } #' @keywords internal #' @importFrom rlang .data diff --git a/R/utils.R b/R/utils.R index 5b3473fe..b5072337 100644 --- a/R/utils.R +++ b/R/utils.R @@ -10,88 +10,9 @@ check_status <- function(res) { } # read qs files form an url qs_from_url <- function(url) qs::qdeserialize(curl::curl_fetch_memory(url)$content) -#' Load cfbfastR play-by-play -#' @name load_cfb_pbp -NULL -#' Load cleaned pbp from the data repo -#' @rdname load_cfb_pbp -#' @description helper that loads multiple seasons from the data repo either into memory -#' or writes it into a db using some forwarded arguments in the dots -#' @param seasons A vector of 4-digit years associated with given College Football seasons. -#' @param ... Additional arguments passed to an underlying function that writes -#' the season data into a database (used by \code{\link[=update_cfb_db]{update_cfb_db()}}). -#' @param qs Wheter to use the function [qs::qdeserialize()] for more efficient loading. -#' @export -load_cfb_pbp <- function(seasons, ..., qs = FALSE) { - dots <- rlang::dots_list(...) - - if (all(c("dbConnection", "tablename") %in% names(dots))) in_db <- TRUE else in_db <- FALSE - - if (isTRUE(qs) && !is_installed("qs")) { - usethis::ui_stop("Package {usethis::ui_value('qs')} required for argument {usethis::ui_value('qs = TRUE')}. Please install it.") - } - - most_recent <- most_recent_season() - - if (!all(seasons %in% 2014:most_recent)) { - usethis::ui_stop("Please pass valid seasons between 2014 and {most_recent}") - } - - if (length(seasons) > 1 && is_sequential() && isFALSE(in_db)) { - usethis::ui_info(c( - "It is recommended to use parallel processing when trying to load multiple seasons.", - "Please consider running {usethis::ui_code('future::plan(\"multisession\")')}!", - "Will go on sequentially..." - )) - } - - p <- progressr::progressor(along = seasons) - - if (isFALSE(in_db)) { - out <- furrr::future_map_dfr(seasons, cfb_single_season, p = p, qs = qs) - } - - if (isTRUE(in_db)) { - purrr::walk(seasons, cfb_single_season, p, ..., qs = qs) - out <- NULL - } - - return(out) -} -cfb_single_season <- function(season, p, dbConnection = NULL, tablename = NULL, qs = FALSE) { - if (isTRUE(qs)) { - - .url <- glue::glue("https://github.com/saiemgilani/cfbfastR-data/blob/master/data/rds/pbp_players_pos_{season}.qs") - pbp <- qs_from_url(.url) - - } - if (isFALSE(qs)) { - .url <- glue::glue("https://raw.githubusercontent.com/saiemgilani/cfbfastR-data/master/data/rds/pbp_players_pos_{season}.rds") - con <- url(.url) - pbp <- readRDS(con) - close(con) - } - if (!is.null(dbConnection) && !is.null(tablename)) { - DBI::dbWriteTable(dbConnection, tablename, pbp, append = TRUE) - out <- NULL - } else { - out <- pbp - } - p(sprintf("season=%g", season)) - return(out) -} - -# load games file -load_games <- function(){ - .url <- "https://raw.githubusercontent.com/saiemgilani/cfbfastR-data/master/data/games_in_data_repo.csv" - con <- url(.url) - dat <- utils::read.csv(con) - # close(con) - return (dat) -} # The function `message_completed` to create the green "...completed" message # only exists to hide the option `in_builder` in dots message_completed <- function(x, in_builder = FALSE) { diff --git a/R/zzz.R b/R/zzz.R index aa51f88e..91171147 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -45,7 +45,7 @@ load_wp_model <- function(){ ##' @importFrom utils packageVersion ##' @examples ##' \dontrun{ -##' check_github('saiemgilani/cfbfastR') +##' cfbfastR:::check_github('saiemgilani/cfbfastR') ##' } check_github <- function(pkg) { installed_version <- tryCatch(utils::packageVersion(gsub(".*/", "", pkg)), error=function(e) NA) diff --git a/README.Rmd b/README.Rmd index ee32e3d7..2b43a428 100644 --- a/README.Rmd +++ b/README.Rmd @@ -29,10 +29,12 @@ raw_data <- issue::get_issues( tbl <- raw_data%>% issue::issue_tibble() -tbl <- tbl[tbl$pull_request==FALSE,] -x <- tbl%>% +open_tbl <- tbl[tbl$pull_request==FALSE & tbl$state=="open",] +closed_tbl <- tbl[tbl$state=="closed",] +x <- open_tbl %>% + issue::md_table() +x2 <- closed_tbl %>% issue::md_table() - ``` @@ -46,8 +48,7 @@ x <- tbl%>% - -The goal of [**```cfbfastR```**](https://saiemgilani.github.io/cfbfastR/) is to provide the community with an R package for working with CFB data. It is an R API wrapper around [https://collegefootballdata.com/](https://collegefootballdata.com/). +The goal of [**```cfbfastR```**](https://saiemgilani.github.io/cfbfastR/) is to provide the community with an R package for working with CFB data. It is an R API wrapper around [https://collegefootballdata.com/](https://collegefootballdata.com/). Beyond data aggregation and tidying ease, one of the multitude of services that [**```cfbfastR```**](https://saiemgilani.github.io/cfbfastR/) provides is for benchmarking open-source expected points and win probability metrics. ## **Installation** @@ -58,7 +59,7 @@ You can install the released version of [**```cfbfastR```**](https://github.com/ if (!requireNamespace('pacman', quietly = TRUE)){ install.packages('pacman') } -pacman::p_load_gh("saiemgilani/cfbfastR") +pacman::p_load_current_gh("saiemgilani/cfbfastR") ``` ``` r @@ -69,7 +70,28 @@ if (!requireNamespace('devtools', quietly = TRUE)){ # Alternatively, using the devtools package: devtools::install_github(repo = "saiemgilani/cfbfastR") ``` + ## **Breaking Changes** + +### **v1.2.0** +#### **Add significant documentation to the package** + +* Added mini-vignettes pertaining to CFB Data functionality: + - [```cfbd_betting```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_betting.html), + - [```cfbd_games```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_games.html), + - [```cfbd_plays```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_plays.html), + - [```cfbd_recruiting```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_recruiting.html), + - [```cfbd_stats```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_stats.html), + - [```cfbd_teams```](https://saiemgilani.github.io/cfbfastR/articles/cfbd_teams.html) + +* [Introductory vignette stub](https://saiemgilani.github.io/cfbfastR/articles/intro.html) added + +#### **ESPN/CFBD metrics function variable return standardization** + +* Change `id` variable to `team_id` in [```espn_ratings_fpi()```](https://saiemgilani.github.io/cfbfastR/reference/espn_ratings.html) +* Changed `espn_game_id` variable to `game_id` in [```espn_metrics_wp()```](https://saiemgilani.github.io/cfbfastR/reference/espn_metrics.html), corrected the `away_win_percentage` calculation and added `tie_percentage` to the returns. +* Change `id` variable to `athlete_id` in [```cfbd_metrics_ppa_players_season()```](https://saiemgilani.github.io/cfbfastR/reference/cfbd_metrics.html) + ### **v1.1.0** #### **Add loading from Data Repository functionality** @@ -87,7 +109,7 @@ devtools::install_github(repo = "saiemgilani/cfbfastR") * Similarly, data and metrics sourced from ESPN will begin with `espn_` as opposed to `cfb_`. In particular, the two functions are now [```espn_ratings_fpi()```](https://saiemgilani.github.io/cfbfastR/reference/espn_ratings.html) and [```espn_metrics_wp()```](https://saiemgilani.github.io/cfbfastR/reference/espn_metrics.html) -* Data generated from any of the ```cfbfastR``` methods will use `cfb_` +* Data generated from any of the [```cfbfastR```](https://saiemgilani.github.io/cfbfastR/) methods will use `cfb_` #### **CollegeFootballData API Keys** @@ -122,7 +144,7 @@ x[c(1:(min(nrow(x),5))),] %>%
View More ```{r,results='asis',echo=FALSE} -x[-c(1:(min(nrow(x),5))),] %>% +x2[c(1:(min(nrow(x),5))),] %>% knitr::kable() ``` @@ -181,6 +203,6 @@ x[-c(1:(min(nrow(x),5))),] %>% ## **Special Thanks** - [Nick Tice](https://github.com/NickTice) -- [Sebastian Carl](https://twitter.com/mrcaseb) +- [Sebastian Carl](https://twitter.com/mrcaseb) @mrcaseb @mrcaseb diff --git a/README.md b/README.md index 1876629e..40b8df0b 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ You can install the released version of if (!requireNamespace('pacman', quietly = TRUE)){ install.packages('pacman') } -pacman::p_load_gh("saiemgilani/cfbfastR") +pacman::p_load_current_gh("saiemgilani/cfbfastR") ``` ``` r @@ -41,6 +41,21 @@ devtools::install_github(repo = "saiemgilani/cfbfastR") ## **Breaking Changes** +### **v1.2.0** + +#### **Add significant documentation to the package** + + - Added mini-vignettes pertaining to CFB Data functionality: + - [`cfbd_betting`](https://saiemgilani.github.io/cfbfastR/articles/cfbd_betting.html), + - [`cfbd_games`](https://saiemgilani.github.io/cfbfastR/articles/cfbd_games.html), + - [`cfbd_plays`](https://saiemgilani.github.io/cfbfastR/articles/cfbd_plays.html), + - [`cfbd_recruiting`](https://saiemgilani.github.io/cfbfastR/articles/cfbd_recruiting.html), + - [`cfbd_stats`](https://saiemgilani.github.io/cfbfastR/articles/cfbd_stats.html), + - [`cfbd_teams`](https://saiemgilani.github.io/cfbfastR/articles/cfbd_teams.html) + - [Introductory + vignette](https://saiemgilani.github.io/cfbfastR/articles/intro.html) + added + ### **v1.1.0** #### **Add loading from Data Repository functionality** @@ -86,7 +101,9 @@ devtools::install_github(repo = "saiemgilani/cfbfastR") and [`espn_metrics_wp()`](https://saiemgilani.github.io/cfbfastR/reference/espn_metrics.html) - - Data generated from any of the `cfbfastR` methods will use `cfb_` + - Data generated from any of the + [`cfbfastR`](https://saiemgilani.github.io/cfbfastR/) methods will + use `cfb_` #### **CollegeFootballData API Keys** @@ -128,17 +145,17 @@ Sys.setenv(CFBD_API_KEY = "XXXX-YOUR-API-KEY-HERE-XXXXX") ## Current Issues -| issue | icon | title | labels | opened\_by | comments | comments\_users | assigned\_to | created | updated | closed | -| :---- | :----------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ | :------------------------------------ | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------- | :------------------ | :------------------ | :------------------ | -| 5 | | [Play by play for data 2013 and before](https://github.com/saiemgilani/cfbfastR/issues/5) | bug | [rchanks](https://github.com/rchanks) | 1 | [saiemgilani](https://github.com/saiemgilani/cfbfastR/issues/5#issuecomment-820774185) | saiemgilani | 2021-04-15 16:24:03 | 2021-04-15 22:48:48 | NA | -| 4 | | [cfbd\_play\_types is documented, but isn’t in the package](https://github.com/saiemgilani/cfbfastR/issues/4) | documentation | [rchanks](https://github.com/rchanks) | 1 | [saiemgilani](https://github.com/saiemgilani/cfbfastR/issues/4#issuecomment-820774552) | saiemgilani | 2021-04-15 16:11:17 | 2021-04-18 23:47:31 | 2021-04-18 23:47:31 | +| issue | icon | title | labels | opened\_by | comments | comments\_users | assigned\_to | created | updated | closed | +| :---- | :--------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------- | :----- | :------------------------------------ | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------- | :------------------ | :------------------ | :----- | +| 5 | | [Play by play for data 2013 and before](https://github.com/saiemgilani/cfbfastR/issues/5) | bug | [rchanks](https://github.com/rchanks) | 1 | [saiemgilani](https://github.com/saiemgilani/cfbfastR/issues/5#issuecomment-820774185) | saiemgilani | 2021-04-15 16:24:03 | 2021-04-15 22:48:48 | NA |
View More -| issue | icon | title | labels | opened\_by | comments | comments\_users | assigned\_to | created | updated | closed | -| :---- | :--- | :---- | :----- | :--------- | :------- | :-------------- | :----------- | :------ | :------ | :----- | +| issue | icon | title | labels | opened\_by | comments | comments\_users | assigned\_to | created | updated | closed | +| :---- | :----------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ | :------------------------------------ | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------- | :------------------ | :------------------ | :------------------ | +| 4 | | [cfbd\_play\_types is documented, but isn’t in the package](https://github.com/saiemgilani/cfbfastR/issues/4) | documentation | [rchanks](https://github.com/rchanks) | 1 | [saiemgilani](https://github.com/saiemgilani/cfbfastR/issues/4#issuecomment-820774552) | saiemgilani | 2021-04-15 16:11:17 | 2021-04-18 23:47:31 | 2021-04-18 23:47:31 |
@@ -195,6 +212,6 @@ Sys.setenv(CFBD_API_KEY = "XXXX-YOUR-API-KEY-HERE-XXXXX") ## **Special Thanks** - [Nick Tice](https://github.com/NickTice) - - [Sebastian Carl](https://twitter.com/mrcaseb) + - [Sebastian Carl](https://twitter.com/mrcaseb) @mrcaseb @mrcaseb diff --git a/_pkgdown.yml b/_pkgdown.yml index 62512197..0d1272a0 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,7 +1,8 @@ url: http://saiemgilani.github.io/cfbfastR title: cfbfastR - +description: "An R package to quickly obtain clean and tidy college football play by play data" +alt: "When you code good, you know good. When you know good, you win good. When you win good, they pay good." template: params: bootswatch: cosmo @@ -14,7 +15,7 @@ template: alt: "When you code good, you know good. When you know good, you win good. When you win good, they pay good." twitter: site: "@cfbfastR" - card: summary_large_image + card: summary toc: depth: 3 @@ -54,7 +55,7 @@ home: navbar: structure: - left: [home, intro, reference, news, articles, data, games, network] + left: [home, intro, reference, articles, news, games, network, data] right: [twitter, github] components: twitter: @@ -83,14 +84,33 @@ navbar: menu: - text: "Function Index" href: reference/index.html - - text: "CFBD API Keys" - href: reference/register_cfbd.html - - text: "Play-by-Play Data" - href: reference/cfbd_pbp_data.html + - text: -------------------------------- + - text: cfbfastR Data - text: "Load Full Season PBP Data" href: reference/load_cfb_pbp.html - text: "Update or Create Database" href: reference/update_cfb_db.html + - text: "Play-by-Play Data" + href: reference/cfbd_pbp_data.html + - text: -------------------------------- + - text: CFB Data + - text: Using the API + menu: + - text: "Tutorials" + - text: "CFBD Betting" + href: articles/cfbd_betting.html + - text: "CFBD Games" + href: articles/cfbd_games.html + - text: "CFBD Plays" + href: articles/cfbd_plays.html + - text: "CFBD Recruiting" + href: articles/cfbd_recruiting.html + - text: "CFBD Stats" + href: articles/cfbd_stats.html + - text: "CFBD Teams" + href: articles/cfbd_teams.html + - text: "CFBD API Keys" + href: reference/register_cfbd.html - text: "Games" href: reference/cfbd_games.html - text: "Plays" @@ -105,12 +125,8 @@ navbar: href: reference/cfbd_stats.html - text: "Metrics" href: reference/cfbd_metrics.html - - text: "ESPN Metrics" - href: reference/espn_metrics.html - text: "Ratings" href: reference/cfbd_ratings.html - - text: "ESPN Ratings" - href: reference/espn_ratings.html - text: "Betting" href: reference/cfbd_betting.html - text: "Recruiting" @@ -121,6 +137,12 @@ navbar: href: reference/cfbd_conferences.html - text: "Venues" href: reference/cfbd_venues.html + - text: --------------------------------- + - text: ESPN Data + - text: "ESPN Metrics" + href: reference/espn_metrics.html + - text: "ESPN Ratings" + href: reference/espn_ratings.html articles: icon: "fas fa-book-reader" text: "Articles" @@ -138,6 +160,7 @@ navbar: href: articles/rolling-epa-graph.html - text: Visualizing Team Talent with Player Recruit Rankings href: articles/nth-rated-recruit.html + - text: -------------------------------- - text: Expected Points Model Fundamentals - text: "Part 1 - Model Definition" href: articles/college-football-expected-points-model-fundamentals-part-i.html @@ -222,39 +245,9 @@ reference: - '`cfbd_venues`' - '`cfbd_conferences`' - '`cfbd_coaches`' - # - subtitle: Plotting Functions - # desc: Plotting play-by-play sequences and game win probability charts - # contents: - # - '`plot_wpa`' - # - '`plot_pbp_sequencing`' - # - '`plot_away_travel`' - subtitle: Internals desc: Internal functions and helpers contents: - - '`ep_fg_model_select`' - - '`get_preds_ep`' - '`create_epa`' - - '`epa_fg_probs`' - - '`create_wpa_naive`' - - '`create_wpa_betting`' - - '`add_betting_cols`' - - '`clean_drive_info`' - - '`penalty_detection`' - - '`add_play_counts`' - - '`clean_pbp_dat`' - - '`clean_drive_dat`' - - '`prep_epa_df_after`' - - '`ep_model_select`' - - '`ep_model_select_check`' - - '`wp_model_select`' - - '`wp_model_select_check`' - - '`penalty_detection_select`' - - '`add_play_counts_select`' - - '`clean_pbp_dat_select`' - - '`clean_drive_dat_select`' - - '`add_player_cols_select`' - - '`add_yardage_select`' - - '`prep_epa_df_after_select`' - - '`prep_df_pbp_overview`' - - '`check_internet`' - + - '`create_wpa`' + - '`helpers_pbp`' diff --git a/man/add_play_counts.Rd b/man/add_play_counts.Rd deleted file mode 100644 index 27abe571..00000000 --- a/man/add_play_counts.Rd +++ /dev/null @@ -1,98 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/cfbd_pbp_data.R -\name{add_play_counts} -\alias{add_play_counts} -\title{Adds play counts to Play-by-Play data -Adds play counts to Play-by-Play data pulled from the API's raw game data} -\usage{ -add_play_counts(play_df) -} -\arguments{ -\item{play_df}{(\emph{data.frame} required): Adds play counts to Play-by-Play dataframe, as pulled from \code{cfbd_pbp_data()}} -} -\value{ -The original \code{play_df} with the following columns appended/redefined: -\describe{ -\item{game_play_number}{.} -\item{half_clock.minutes}{.} -\item{TimeSecsRem}{.} -\item{Under_two}{.} -\item{half}{.} -\item{kickoff_play}{.} -\item{pos_team}{.} -\item{def_pos_team}{.} -\item{receives_2H_kickoff}{.} -\item{pos_score_diff}{.} -\item{lag_pos_score_diff}{.} -\item{lag_pos_team}{.} -\item{lead_pos_team}{.} -\item{lead_pos_team2}{.} -\item{pos_score_pts}{.} -\item{pos_score_diff_start}{.} -\item{score_diff}{.} -\item{lag_score_diff}{.} -\item{lag_offense_play}{.} -\item{lead_offense_play}{.} -\item{lead_offense_play2}{.} -\item{score_pts}{.} -\item{score_diff_start}{.} -\item{offense_receives_2H_kickoff}{.} -\item{half_play_number}{.} -\item{lag_off_timeouts}{.} -\item{lag_def_timeouts}{.} -\item{off_timeouts_rem_before}{.} -\item{def_timeouts_rem_before}{.} -\item{off_timeout_called}{.} -\item{def_timeout_called}{.} -\item{lead_TimeSecsRem}{.} -\item{lead_TimeSecsRem2}{.} -\item{lead_yards_to_goal}{.} -\item{lead_yards_to_goal2}{.} -\item{lead_down}{.} -\item{lead_down2}{.} -\item{lag_distance3}{.} -\item{lag_distance2}{.} -\item{lag_distance}{.} -\item{lead_distance}{.} -\item{lead_distance2}{.} -\item{end_of_half}{.} -\item{lag_play_type3}{.} -\item{lag_play_type2}{.} -\item{lag_play_type}{.} -\item{lead_play_type}{.} -\item{lead_play_type2}{.} -\item{lead_play_type3}{.} -\item{change_of_poss}{.} -\item{change_of_pos_team}{.} -\item{pos_team_timeouts}{.} -\item{def_pos_team_timeouts}{.} -\item{pos_team_timeouts_rem_before}{.} -\item{def_pos_team_timeouts_rem_before}{.} -} -} -\description{ -Adds play counts to Play-by-Play data -Adds play counts to Play-by-Play data pulled from the API's raw game data -} -\details{ -Requires the following columns to be present -\describe{ -\item{game_id}{.} -\item{id_play}{.} -\item{clock.minutes}{.} -\item{clock.seconds}{.} -\item{half}{.} -\item{period}{.} -\item{offense_play}{.} -\item{defense_play}{.} -\item{home}{.} -\item{away}{.} -\item{offense_score}{.} -\item{defense_score}{.} -\item{offense_timeouts}{.} -\item{offense_timeouts}{.} -\item{play_text}{.} -\item{play_type}{.} -} -} -\keyword{internal} diff --git a/man/add_player_cols.Rd b/man/add_player_cols.Rd deleted file mode 100644 index 8cb3897d..00000000 --- a/man/add_player_cols.Rd +++ /dev/null @@ -1,50 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helper_pbp_add_player_cols.R -\name{add_player_cols} -\alias{add_player_cols} -\title{Add player columns extracted from play text} -\usage{ -add_player_cols(pbp) -} -\arguments{ -\item{play_df}{(\emph{data.frame} required) Extracts player name information from Play-by-Play data frame, as pulled from \code{cfbd_pbp_data()}} -} -\value{ -The original \code{pbp} with the following columns appended to it: -\describe{ -\item{rusher_player_name}{.} -\item{receiver_player_name}{.} -\item{passer_player_name}{.} -\item{sack_player_name}{.} -\item{sack_player_name2}{.} -\item{pass_breakup_player_name}{.} -\item{interception_player_name}{.} -\item{fg_kicker_player_name}{.} -\item{fg_block_player_name}{.} -\item{fg_return_player_name}{.} -\item{kickoff_player_name}{.} -\item{kickoff_returner_player_name}{.} -\item{punter_player_name}{.} -\item{punt_block_player_name}{.} -\item{punt_returner_player_name}{.} -\item{punt_block_return_player_name}{.} -\item{fumble_player_name}{.} -\item{fumble_forced_player_name}{.} -\item{fumble_recovered_player_name}{.} -} -} -\description{ -Add player columns extracted from play text -} -\details{ -Cleans CFB (D-I) player Data to create player name columns. Requires the following columns be present: -\itemize{ -\item{rush}{.} -\item{pass}{.} -\item{play_text}{} -\item{play_type}{.} -\item{sack}{.} -\item{fumble_vec}{.} -} -} -\keyword{internal} diff --git a/man/add_yardage.Rd b/man/add_yardage.Rd deleted file mode 100644 index 93da2a80..00000000 --- a/man/add_yardage.Rd +++ /dev/null @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helper_pbp_add_yardage.R -\name{add_yardage} -\alias{add_yardage} -\title{Add yardage extracted from play text} -\usage{ -add_yardage(play_df) -} -\arguments{ -\item{play_df}{(\emph{data.frame} required) Extracts yardage information from Play-by-Play data frame, as pulled from \code{cfbd_pbp_data()}} -} -\value{ -The original \code{play_df} with the following columns appended to it: -\describe{ -\item{yds_rushed}{.} -\item{yds_receiving}{.} -\item{yds_int_return}{.} -\item{yds_kickoff}{.} -\item{yds_kickoff_return}{.} -\item{yds_punted}{.} -\item{yds_fumble_return}{.} -\item{yds_sacked}{.} -\item{yds_penalty}{.} -} -} -\description{ -Add yardage extracted from play text -} -\details{ -Cleans CFB (D-I) Drive-By-Drive Data to create yardage column. Requires the following columns be present: -\describe{ -\item{play_text}{.} -\item{play_type}{.} -\item{rush}{.} -\item{pass}{.} -\item{int}{.} -\item{int_td}{.} -\item{kickoff_play}{.} -\item{kickoff_tb}{.} -\item{kickoff_downed}{.} -\item{kickoff_fair_catch}{.} -\item{fumble_vec}{.} -\item{sack}{.} -\item{punt}{.} -\item{punt_tb}{.} -\item{punt_downed}{.} -\item{punt_fair_catch}{.} -\item{punt_oob}{.} -\item{punt_blocked}{.} -\item{penalty_detail}{.} -} -} -\keyword{internal} diff --git a/man/cfbd_betting.Rd b/man/cfbd_betting.Rd index e2231b3d..f3d57b92 100644 --- a/man/cfbd_betting.Rd +++ b/man/cfbd_betting.Rd @@ -1,9 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/cfbd_betting_lines.R +% Please edit documentation in R/cfbd_betting.R \name{cfbd_betting} \alias{cfbd_betting} \alias{cfbd_betting_lines} -\title{CFBD Betting Endpoint} +\alias{betting} +\title{CFBD Betting Lines Endpoint} \source{ \url{https://api.collegefootballdata.com/lines} } @@ -23,7 +24,7 @@ cfbd_betting_lines( } \arguments{ \item{game_id}{(\emph{Integer} optional): Game ID filter for querying a single game -Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function} +Can be found using the \code{\link[=cfbd_game_info]{cfbd_game_info()}} function} \item{year}{(\emph{Integer} required): Year, 4 digit format(\emph{YYYY})} @@ -39,7 +40,7 @@ Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_ \item{conference}{(\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr -Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC\cr} +Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC} \item{line_provider}{(\emph{String} optional): Select Line Provider - Caesars, consensus, numberfire, or teamrankings} @@ -48,26 +49,24 @@ Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC\ \value{ Betting information for games with the following columns: \describe{ -\item{\code{game_id}}{integer. Unique game identifier - \code{game_id}.} -\item{\code{season}}{integer. Season parameter.} -\item{\code{season_type}}{character. Season Type (regular, postseason, both).} -\item{\code{week}}{integer. Week, values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier).} -\item{\code{home_team}}{character. Home D-I Team.} -\item{\code{home_conference}}{character. Home D-I Conference.} -\item{\code{home_score}}{integer. Home Score.} -\item{\code{away_team}}{character. Away D-I Team.} -\item{\code{away_conference}}{character. Away D-I Conference.} -\item{\code{away_score}}{integer. Away Score.} -\item{\code{provider}}{character. Line provider.} -\item{\code{spread}}{character. Spread for the game.} -\item{\code{formatted_spread}}{character. Formatted spread for the game.} -\item{\code{over_under}}{character. Over/Under for the game.} +\item{\code{game_id}:integer.}{Unique game identifier - \code{game_id}.} +\item{\code{season}:integer.}{Season parameter.} +\item{\code{season_type}:character.)}{Season Type (regular, postseason, both} +\item{\code{week}:integer.}{Week, values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier).} +\item{\code{home_team}:character.}{Home D-I Team.} +\item{\code{home_conference}:character.}{Home D-I Conference.} +\item{\code{home_score}:integer.}{Home Score.} +\item{\code{away_team}:character.}{Away D-I Team.} +\item{\code{away_conference}:character.}{Away D-I Conference.} +\item{\code{away_score}:integer.}{Away Score.} +\item{\code{provider}:character.}{Line provider.} +\item{\code{spread}:character.}{Spread for the game.} +\item{\code{formatted_spread}:character.}{Formatted spread for the game.} +\item{\code{over_under}:character.}{Over/Under for the game.} } } \description{ -CFBD Betting Endpoint - -Get Betting information from games +Get betting lines information from games } \examples{ \donttest{ @@ -76,7 +75,6 @@ Get Betting information from games # 7 OTs LSU at TAMU cfbd_betting_lines(year = 2018, week = 13, team = "Texas A&M", conference = "SEC") } - } \keyword{Betting} \keyword{Lines} diff --git a/man/cfbd_coaches.Rd b/man/cfbd_coaches.Rd index 3f81f53e..c6789fbe 100644 --- a/man/cfbd_coaches.Rd +++ b/man/cfbd_coaches.Rd @@ -2,7 +2,8 @@ % Please edit documentation in R/cfbd_coaches.R \name{cfbd_coaches} \alias{cfbd_coaches} -\title{Coach Information Search} +\alias{coaches} +\title{CFBD Coaches Endpoint} \source{ \url{https://api.collegefootballdata.com/coaches} } @@ -33,30 +34,32 @@ cfbd_coaches( \item{verbose}{Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function} } \value{ -\code{\link[cfbfastR:cfbd_coaches]{cfbfastR::cfbd_coaches()}} - A data frame with coach information with the following columns: +\code{\link[=cfbd_coaches]{cfbd_coaches()}} - A data frame with coach information with the following columns: \describe{ -\item{\code{first_name}}{character. First name of coach.} -\item{\code{last_name}}{character. Last name of coach.} -\item{\code{school}}{character. School of coach.} -\item{\code{year}}{integer. Season of record.} -\item{\code{games}}{integer. Games as coach.} -\item{\code{wins}}{integer. Wins for the season.} -\item{\code{losses}}{integer. Losses for the season.} -\item{\code{ties}}{integer. Ties for the season.} -\item{\code{preseason_rank}}{integer. Preseason rank for the school of coach.} -\item{\code{postseason_rank}}{integer. Postseason rank for the school of coach.} -\item{\code{srs}}{character. Simple Rating System adjustment for team.} -\item{\code{sp_overall}}{character. Bill Connelly's SP+ overall for team.} -\item{\code{sp_offense}}{character. Bill Connelly's SP+ offense for team.} -\item{\code{sp_defense}}{character. Bill Connelly's SP+ defense for team.} +\item{\code{first_name}:character.}{First name of coach.} +\item{\code{last_name}:character.}{Last name of coach.} +\item{\code{school}:character.}{School of coach.} +\item{\code{year}:integer.}{Season of record.} +\item{\code{games}:integer.}{Games as coach.} +\item{\code{wins}:integer.}{Wins for the season.} +\item{\code{losses}:integer.}{ Losses for the season.} +\item{\code{ties}:integer.}{Ties for the season.} +\item{\code{preseason_rank}:integer.}{Preseason rank for the school of coach.} +\item{\code{postseason_rank}:integer.}{Postseason rank for the school of coach.} +\item{\code{srs}:character.}{Simple Rating System adjustment for team.} +\item{\code{sp_overall}:character.}{Bill Connelly's SP+ overall for team.} +\item{\code{sp_offense}:character.}{Bill Connelly's SP+ offense for team.} +\item{\code{sp_defense}:character.}{Bill Connelly's SP+ defense for team.} } } \description{ -A coach search function which provides coaching records and school history for a given coach +Coach Information Search +A coach search function which provides coaching records and school history for a given coach\if{html}{\out{
}}\preformatted{cfbd_coaches(first = "Nick", last = "Saban", team = "alabama") +}\if{html}{\out{
}} } \examples{ \donttest{ cfbd_coaches(first = "Nick", last = "Saban", team = "alabama") } } -\keyword{Recruiting} +\keyword{Coaches} diff --git a/man/cfbd_conferences.Rd b/man/cfbd_conferences.Rd index e653de4d..467d0758 100644 --- a/man/cfbd_conferences.Rd +++ b/man/cfbd_conferences.Rd @@ -2,7 +2,8 @@ % Please edit documentation in R/cfbd_conferences.R \name{cfbd_conferences} \alias{cfbd_conferences} -\title{CFB Conference Information} +\alias{conferences} +\title{CFBD Conferences Endpoint} \source{ \url{https://api.collegefootballdata.com/conferences} } @@ -10,17 +11,21 @@ cfbd_conferences() } \value{ -\code{\link[cfbfastR:cfbd_conferences]{cfbfastR::cfbd_conferences()}} - A data frame with 11 rows and 4 variables: +\code{\link[=cfbd_conferences]{cfbd_conferences()}} - A data frame with 11 rows and 4 variables: \describe{ -\item{conference_id}{Referencing conference id} -\item{name}{Conference name} -\item{long_name}{Long name for Conference} -\item{abbreviation}{Conference abbreviation} +\item{\code{conference_id}:}{Referencing conference id.} +\item{\code{name}:}{Conference name.} +\item{\code{long_name}:}{Long name for Conference.} +\item{\code{abbreviation}:}{Conference abbreviation.} ... } } \description{ -Pulls all college football conferences and returns as data frame the following fields: +CFB Conference Information +Pulls all college football conferences and returns as data frame + +You can call this function simply with\if{html}{\out{
}}\preformatted{cfbd_conferences() +}\if{html}{\out{
}} } \examples{ \donttest{ diff --git a/man/cfbd_drives.Rd b/man/cfbd_drives.Rd index 4adacd76..fa179834 100644 --- a/man/cfbd_drives.Rd +++ b/man/cfbd_drives.Rd @@ -2,24 +2,11 @@ % Please edit documentation in R/cfbd_drives.R \name{cfbd_drives} \alias{cfbd_drives} -\title{Get results information from games} +\alias{drives} +\title{CFBD Drives Endpoint} \source{ \url{https://api.collegefootballdata.com/drives} } -\usage{ -cfbd_drives( - year, - season_type = "regular", - week = NULL, - team = NULL, - offense_team = NULL, - defense_team = NULL, - conference = NULL, - offense_conference = NULL, - defense_conference = NULL, - verbose = FALSE -) -} \arguments{ \item{year}{(\emph{Integer} required): Year, 4 digit format (\emph{YYYY})} @@ -48,42 +35,49 @@ Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC} \item{verbose}{Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function} } \value{ -\code{\link[cfbfastR:cfbd_drives]{cfbfastR::cfbd_drives()}} - A data frame with 23 variables as follows: +\code{\link[=cfbd_drives]{cfbd_drives()}} - A data frame with 23 variables as follows: \describe{ -\item{\code{offense}}{character. Drive offense.} -\item{\code{offense_conference}}{character. Drive offense's conference.} -\item{\code{defense}}{character. Drive defense.} -\item{\code{defense_conference}}{character. Drive defense's conference.} -\item{\code{game_id}}{integer. Unique game identifier - \code{game_id}.} -\item{\code{drive_id}}{character. Unique drive identifier - \code{drive_id}.} -\item{\code{drive_number}}{integer. Drive number in game.} -\item{\code{scoring}}{logical. Drive ends in a score.} -\item{\code{start_period}}{integer. Period (or Quarter) in which the drive starts.} -\item{\code{start_yardline}}{integer. Yard line at the drive start.} -\item{\code{start_yards_to_goal}}{integer. Yards-to-Goal at the drive start.} -\item{\code{end_period}}{integer. Period (or Quarter) in which the drive ends.} -\item{\code{end_yardline}}{integer. Yard line at drive end.} -\item{\code{end_yards_to_goal}}{integer. Yards-to-Goal at drive end.} -\item{\code{plays}}{integer. Number of drive plays.} -\item{\code{yards}}{integer. Total drive yards.} -\item{\code{drive_result}}{character. Result of the drive description.} -\item{\code{time_minutes_start}}{integer. Minutes at drive start.} -\item{\code{time_seconds_start}}{integer. Seconds at drive start.} -\item{\code{time_minutes_end}}{integer. Minutes at drive end.} -\item{\code{time_seconds_end}}{integer. Seconds at drive end.} -\item{\code{time_minutes_elapsed}}{double. Minutes elapsed during drive.} -\item{\code{time_seconds_elapsed}}{integer. Seconds elapsed during drive.} +\item{\code{offense}:character.}{Drive offense.} +\item{\code{offense_conference}:character.}{Drive offense's conference.} +\item{\code{defense}:character.}{Drive defense.} +\item{\code{defense_conference}:character.}{Drive defense's conference.} +\item{\code{game_id}:integer.}{Unique game identifier - \code{game_id}.} +\item{\code{drive_id}:character.}{Unique drive identifier - \code{drive_id}.} +\item{\code{drive_number}:integer.}{Drive number in game.} +\item{\code{scoring}:logical.}{Drive ends in a score.} +\item{\code{start_period}:integer.}{Period (or Quarter) in which the drive starts.} +\item{\code{start_yardline}:integer.}{Yard line at the drive start.} +\item{\code{start_yards_to_goal}:integer.}{Yards-to-Goal at the drive start.} +\item{\code{end_period}:integer.}{Period (or Quarter) in which the drive ends.} +\item{\code{end_yardline}:integer.}{Yard line at drive end.} +\item{\code{end_yards_to_goal}:integer.}{Yards-to-Goal at drive end.} +\item{\code{plays}:integer.}{Number of drive plays.} +\item{\code{yards}:integer.}{Total drive yards.} +\item{\code{drive_result}:character.}{Result of the drive description.} +\item{\code{is_home_offense}:logical.}{Flag for if the offense on the field is the home offense} +\item{\code{start_offense_score}:numeric.}{Offense score at the start of the drive.} +\item{\code{start_defense_score}:numeric.}{Defense score at the start of the drive.} +\item{\code{end_offense_score}:numeric.}{Offense score at the end of the drive.} +\item{\code{end_defense_score}:numeric.}{Defense score at the end of the drive.} +\item{\code{time_minutes_start}:integer.}{Minutes at drive start.} +\item{\code{time_seconds_start}:integer.}{Seconds at drive start.} +\item{\code{time_minutes_end}:integer.}{Minutes at drive end.} +\item{\code{time_seconds_end}:integer.}{Seconds at drive end.} +\item{\code{time_minutes_elapsed}:double.}{Minutes elapsed during drive.} +\item{\code{time_seconds_elapsed}:integer.}{Seconds elapsed during drive.} } } \description{ -Get results information from games +Get CFB game drives\if{html}{\out{
}}\preformatted{cfbd_drives(2018, week = 1, team = "TCU") + +cfbd_drives(2018, team = "Texas A&M", defense_conference = "SEC") +}\if{html}{\out{
}} } \examples{ \donttest{ - cfbd_drives(2018, week = 1, team = "TCU") +cfbd_drives(2018, week = 1, team = "TCU") - cfbd_drives(2018, team = "Texas A&M", defense_conference = "SEC") +cfbd_drives(2018, team = "Texas A&M", defense_conference = "SEC") } - } \keyword{Drives} diff --git a/man/cfbd_games.Rd b/man/cfbd_games.Rd index cac76ddd..38e074fa 100644 --- a/man/cfbd_games.Rd +++ b/man/cfbd_games.Rd @@ -1,440 +1,431 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/cfbd_games.R -\name{cfbd_games} -\alias{cfbd_games} -\alias{cfbd_game_info} -\alias{cfbd_calendar} -\alias{cfbd_game_media} -\alias{cfbd_game_box_advanced} -\alias{cfbd_game_player_stats} -\alias{cfbd_game_records} -\alias{cfbd_game_team_stats} -\title{CFBD Games Endpoint} -\source{ -\url{https://api.collegefootballdata.com/games} - -\url{https://api.collegefootballdata.com/calendar} - -\url{https://api.collegefootballdata.com/games/media} - -\url{https://api.collegefootballdata.com/game/box/advanced} - -\url{https://api.collegefootballdata.com/games/players} - -\url{https://api.collegefootballdata.com/records} - -\url{https://api.collegefootballdata.com/games/teams} -} -\usage{ -cfbd_game_info( - year, - week = NULL, - season_type = "regular", - team = NULL, - home_team = NULL, - away_team = NULL, - conference = NULL, - game_id = NULL, - quarter_scores = FALSE, - verbose = FALSE -) - -cfbd_calendar(year, verbose = FALSE) - -cfbd_game_media( - year, - week = NULL, - season_type = "both", - team = NULL, - conference = NULL, - media_type = NULL, - verbose = FALSE -) - -cfbd_game_box_advanced(game_id, long = FALSE, verbose = FALSE) - -cfbd_game_player_stats( - year, - week = NULL, - season_type = "regular", - team = NULL, - conference = NULL, - category = NULL, - game_id = NULL, - verbose = FALSE -) - -cfbd_game_records(year, team = NULL, conference = NULL, verbose = FALSE) - -cfbd_game_team_stats( - year, - week = NULL, - season_type = "regular", - team = NULL, - conference = NULL, - game_id = NULL, - rows_per_team = 1, - verbose = FALSE -) -} -\arguments{ -\item{year}{(\emph{Integer} required): Year, 4 digit format (\emph{YYYY})} - -\item{week}{(\emph{Integer} optional): Week - values range from 1-15, 1-14 for seasons pre-playoff, i.e. 2013 or earlier} - -\item{season_type}{(\emph{String} default: regular): Select Season Type - regular, postseason, or both} - -\item{team}{(\emph{String} optional): D-I Team} - -\item{home_team}{(\emph{String} optional): Home D-I Team} - -\item{away_team}{(\emph{String} optional): Away D-I Team} - -\item{conference}{(\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr -Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr -Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC\cr} - -\item{game_id}{(\emph{Integer} optional): Game ID filter for querying a single game\cr -Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function} - -\item{quarter_scores}{(\emph{Logical} default FALSE): This is a parameter to return the -list columns that give the score at each quarter: \code{home_line_scores} and \code{away_line_scores}.\cr -I have defaulted the parameter to false so that you will not have to go to the trouble of dropping it.} - -\item{verbose}{Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function} - -\item{media_type}{(\emph{String} optional): Media type filter: tv, radio, web, ppv, or mobile} - -\item{long}{(\emph{Logical} default \code{FALSE}): Return the data in a long format.} - -\item{category}{(\emph{String} optional): Category filter (e.g defensive)\cr -Offense: passing, receiving, rushing\cr -Defense: defensive, fumbles, interceptions\cr -Special Teams: punting, puntReturns, kicking, kickReturns\cr} - -\item{rows_per_team}{(\emph{Integer} default 1): Both Teams for each game on one or two row(s), Options: 1 or 2} -} -\value{ -\code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} - A data frame with 22 variables: -\describe{ -\item{\code{game_id}}{integer.} -\item{\code{season}}{integer.} -\item{\code{week}}{integer.} -\item{\code{season_type}}{character.} -\item{\code{start_date}}{character.} -\item{\code{start_time_tbd}}{logical.} -\item{\code{neutral_site}}{logical.} -\item{\code{conference_game}}{logical.} -\item{\code{attendance}}{integer.} -\item{\code{venue_id}}{integer.} -\item{\code{venue}}{character.} -\item{\code{home_id}}{integer.} -\item{\code{home_team}}{character.} -\item{\code{home_conference}}{character.} -\item{\code{home_points}}{integer.} -\item{\code{home_post_win_prob}}{character.} -\item{\code{away_id}}{integer.} -\item{\code{away_team}}{character.} -\item{\code{away_conference}}{character.} -\item{\code{away_points}}{integer.} -\item{\code{away_post_win_prob}}{character.} -\item{\code{excitement_index}}{character.} -} - -\code{\link[cfbfastR:cfbd_calendar]{cfbfastR::cfbd_calendar()}} A data frame with 5 variables: - -\code{\link[cfbfastR:cfbd_game_media]{cfbfastR::cfbd_game_media()}} - A data frame with 13 variables: -\describe{ -\item{\code{game_id}}{integer.} -\item{\code{season}}{integer.} -\item{\code{week}}{integer.} -\item{\code{season_type}}{character.} -\item{\code{start_time}}{character.} -\item{\code{is_start_time_tbd}}{logical.} -\item{\code{home_team}}{character.} -\item{\code{home_conference}}{character.} -\item{\code{away_team}}{character.} -\item{\code{away_conference}}{character.} -\item{\code{tv}}{list.} -\item{\code{radio}}{logical.} -\item{\code{web}}{list.} -} - -\code{\link[cfbfastR:cfbd_game_box_advanced]{cfbfastR::cfbd_game_box_advanced()}} - A data frame with 2 rows and 69 variables: -\describe{ -\item{\code{team}}{character.} -\item{\code{plays}}{double.} -\item{\code{ppa_overall_total}}{double.} -\item{\code{ppa_overall_quarter1}}{double.} -\item{\code{ppa_overall_quarter2}}{double.} -\item{\code{ppa_overall_quarter3}}{double.} -\item{\code{ppa_overall_quarter4}}{double.} -\item{\code{ppa_passing_total}}{double.} -\item{\code{ppa_passing_quarter1}}{double.} -\item{\code{ppa_passing_quarter2}}{double.} -\item{\code{ppa_passing_quarter3}}{double.} -\item{\code{ppa_passing_quarter4}}{double.} -\item{\code{ppa_rushing_total}}{double.} -\item{\code{ppa_rushing_quarter1}}{double.} -\item{\code{ppa_rushing_quarter2}}{double.} -\item{\code{ppa_rushing_quarter3}}{double.} -\item{\code{ppa_rushing_quarter4}}{double.} -\item{\code{cumulative_ppa_plays}}{double.} -\item{\code{cumulative_ppa_overall_total}}{double.} -\item{\code{cumulative_ppa_overall_quarter1}}{double.} -\item{\code{cumulative_ppa_overall_quarter2}}{double.} -\item{\code{cumulative_ppa_overall_quarter3}}{double.} -\item{\code{cumulative_ppa_overall_quarter4}}{double.} -\item{\code{cumulative_ppa_passing_total}}{double.} -\item{\code{cumulative_ppa_passing_quarter1}}{double.} -\item{\code{cumulative_ppa_passing_quarter2}}{double.} -\item{\code{cumulative_ppa_passing_quarter3}}{double.} -\item{\code{cumulative_ppa_passing_quarter4}}{double.} -\item{\code{cumulative_ppa_rushing_total}}{double.} -\item{\code{cumulative_ppa_rushing_quarter1}}{double.} -\item{\code{cumulative_ppa_rushing_quarter2}}{double.} -\item{\code{cumulative_ppa_rushing_quarter3}}{double.} -\item{\code{cumulative_ppa_rushing_quarter4}}{double.} -\item{\code{success_rates_overall_total}}{double.} -\item{\code{success_rates_overall_quarter1}}{double.} -\item{\code{success_rates_overall_quarter2}}{double.} -\item{\code{success_rates_overall_quarter3}}{double.} -\item{\code{success_rates_overall_quarter4}}{double.} -\item{\code{success_rates_standard_downs_total}}{double.} -\item{\code{success_rates_standard_downs_quarter1}}{double.} -\item{\code{success_rates_standard_downs_quarter2}}{double.} -\item{\code{success_rates_standard_downs_quarter3}}{double.} -\item{\code{success_rates_standard_downs_quarter4}}{double.} -\item{\code{success_rates_passing_downs_total}}{double.} -\item{\code{success_rates_passing_downs_quarter1}}{double.} -\item{\code{success_rates_passing_downs_quarter2}}{double.} -\item{\code{success_rates_passing_downs_quarter3}}{double.} -\item{\code{success_rates_passing_downs_quarter4}}{double.} -\item{\code{explosiveness_overall_total}}{double.} -\item{\code{explosiveness_overall_quarter1}}{double.} -\item{\code{explosiveness_overall_quarter2}}{double.} -\item{\code{explosiveness_overall_quarter3}}{double.} -\item{\code{explosiveness_overall_quarter4}}{double.} -\item{\code{rushing_power_success}}{double.} -\item{\code{rushing_stuff_rate}}{double.} -\item{\code{rushing_line_yds}}{double.} -\item{\code{rushing_line_yd_avg}}{double.} -\item{\code{rushing_second_lvl_yds}}{double.} -\item{\code{rushing_second_lvl_yd_avg}}{double.} -\item{\code{rushing_open_field_yds}}{double.} -\item{\code{rushing_open_field_yd_avg}}{double.} -\item{\code{havoc_total}}{double.} -\item{\code{havoc_front_seven}}{double.} -\item{\code{havoc_db}}{double.} -\item{\code{scoring_opps_opportunities}}{double.} -\item{\code{scoring_opps_points}}{double.} -\item{\code{scoring_opps_pts_per_opp}}{double.} -\item{\code{field_pos_avg_start}}{double.} -\item{\code{field_pos_avg_starting_predicted_pts}}{double.} -} - -\code{\link[cfbfastR:cfbd_game_player_stats]{cfbfastR::cfbd_game_player_stats()}} - A data frame with 32 variables: -\describe{ -\item{\code{game_id}}{integer.} -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{home_away}}{character.} -\item{\code{points}}{integer.} -\item{\code{category}}{character.} -\item{\code{athlete_id}}{character.} -\item{\code{name}}{character.} -\item{\code{c_att}}{character.} -\item{\code{yds}}{double.} -\item{\code{avg}}{double.} -\item{\code{td}}{double.} -\item{\code{int}}{double.} -\item{\code{qbr}}{double.} -\item{\code{car}}{double.} -\item{\code{long}}{double.} -\item{\code{rec}}{double.} -\item{\code{no}}{double.} -\item{\code{fg}}{character.} -\item{\code{pct}}{double.} -\item{\code{xp}}{character.} -\item{\code{pts}}{double.} -\item{\code{tb}}{double.} -\item{\code{in_20}}{double.} -\item{\code{fum}}{double.} -\item{\code{lost}}{double.} -\item{\code{tot}}{double.} -\item{\code{solo}}{double.} -\item{\code{sacks}}{double.} -\item{\code{tfl}}{double.} -\item{\code{pd}}{double.} -\item{\code{qb_hur}}{double.} -} - -\code{\link[cfbfastR:cfbd_game_records]{cfbfastR::cfbd_game_records()}} - A data frame with 20 variables: -\describe{ -\item{\code{year}}{integer.} -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{division}}{character.} -\item{\code{total_games}}{integer.} -\item{\code{total_wins}}{integer.} -\item{\code{total_losses}}{integer.} -\item{\code{total_ties}}{integer.} -\item{\code{conference_games}}{integer.} -\item{\code{conference_wins}}{integer.} -\item{\code{conference_losses}}{integer.} -\item{\code{conference_ties}}{integer.} -\item{\code{home_games}}{integer.} -\item{\code{home_wins}}{integer.} -\item{\code{home_losses}}{integer.} -\item{\code{home_ties}}{integer.} -\item{\code{away_games}}{integer.} -\item{\code{away_wins}}{integer.} -\item{\code{away_losses}}{integer.} -\item{\code{away_ties}}{integer.} -} - -\code{\link[cfbfastR:cfbd_game_team_stats]{cfbfastR::cfbd_game_team_stats()}} - A data frame with 78 variables: -\describe{ -\item{\code{game_id}}{integer.} -\item{\code{school}}{character.} -\item{\code{conference}}{character.} -\item{\code{home_away}}{character.} -\item{\code{points}}{integer.} -\item{\code{total_yards}}{character.} -\item{\code{net_passing_yards}}{character.} -\item{\code{completion_attempts}}{character.} -\item{\code{passing_tds}}{character.} -\item{\code{yards_per_pass}}{character.} -\item{\code{passes_intercepted}}{character.} -\item{\code{interception_yards}}{character.} -\item{\code{interception_tds}}{character.} -\item{\code{rushing_attempts}}{character.} -\item{\code{rushing_yards}}{character.} -\item{\code{rush_tds}}{character.} -\item{\code{yards_per_rush_attempt}}{character.} -\item{\code{first_downs}}{character.} -\item{\code{third_down_eff}}{character.} -\item{\code{fourth_down_eff}}{character.} -\item{\code{punt_returns}}{character.} -\item{\code{punt_return_yards}}{character.} -\item{\code{punt_return_tds}}{character.} -\item{\code{kick_return_yards}}{character.} -\item{\code{kick_return_tds}}{character.} -\item{\code{kick_returns}}{character.} -\item{\code{kicking_points}}{character.} -\item{\code{fumbles_recovered}}{character.} -\item{\code{fumbles_lost}}{character.} -\item{\code{total_fumbles}}{character.} -\item{\code{tackles}}{character.} -\item{\code{tackles_for_loss}}{character.} -\item{\code{sacks}}{character.} -\item{\code{qb_hurries}}{character.} -\item{\code{interceptions}}{character.} -\item{\code{passes_deflected}}{character.} -\item{\code{turnovers}}{character.} -\item{\code{defensive_tds}}{character.} -\item{\code{total_penalties_yards}}{character.} -\item{\code{possession_time}}{character.} -\item{\code{conference_allowed}}{character.} -\item{\code{home_away_allowed}}{character.} -\item{\code{points_allowed}}{integer.} -\item{\code{total_yards_allowed}}{character.} -\item{\code{net_passing_yards_allowed}}{character.} -\item{\code{completion_attempts_allowed}}{character.} -\item{\code{passing_tds_allowed}}{character.} -\item{\code{yards_per_pass_allowed}}{character.} -\item{\code{passes_intercepted_allowed}}{character.} -\item{\code{interception_yards_allowed}}{character.} -\item{\code{interception_tds_allowed}}{character.} -\item{\code{rushing_attempts_allowed}}{character.} -\item{\code{rushing_yards_allowed}}{character.} -\item{\code{rush_tds_allowed}}{character.} -\item{\code{yards_per_rush_attempt_allowed}}{character.} -\item{\code{first_downs_allowed}}{character.} -\item{\code{third_down_eff_allowed}}{character.} -\item{\code{fourth_down_eff_allowed}}{character.} -\item{\code{punt_returns_allowed}}{character.} -\item{\code{punt_return_yards_allowed}}{character.} -\item{\code{punt_return_tds_allowed}}{character.} -\item{\code{kick_return_yards_allowed}}{character.} -\item{\code{kick_return_tds_allowed}}{character.} -\item{\code{kick_returns_allowed}}{character.} -\item{\code{kicking_points_allowed}}{character.} -\item{\code{fumbles_recovered_allowed}}{character.} -\item{\code{fumbles_lost_allowed}}{character.} -\item{\code{total_fumbles_allowed}}{character.} -\item{\code{tackles_allowed}}{character.} -\item{\code{tackles_for_loss_allowed}}{character.} -\item{\code{sacks_allowed}}{character.} -\item{\code{qb_hurries_allowed}}{character.} -\item{\code{interceptions_allowed}}{character.} -\item{\code{passes_deflected_allowed}}{character.} -\item{\code{turnovers_allowed}}{character.} -\item{\code{defensive_tds_allowed}}{character.} -\item{\code{total_penalties_yards_allowed}}{character.} -\item{\code{possession_time_allowed}}{character.} -} -} -\description{ -CFBD Games Endpoint - -Get results information from games - -Calendar - Returns calendar of weeks by season - -Get Game media information (TV, radio, etc) - -Get game advanced box score information - -Get results information from games - -Get Team records by year - -Get Team Statistics by Game -} -\examples{ -\donttest{ - cfbd_game_info(2018, week = 1) - - cfbd_game_info(2018, week = 7, conference = "Ind") - - # 7 OTs LSU @ TAMU - cfbd_game_info(2018, week = 13, team = "Texas A&M", quarter_scores = TRUE) -} -\donttest{ -cfbd_calendar(2019) -} - - -\donttest{ - cfbd_game_media(2019, week = 4, conference = "ACC") -} -\donttest{ - cfbd_game_box_advanced(game_id = 401114233) -} -\donttest{ - cfbd_game_player_stats(2018, week = 15, conference = "Ind") - - cfbd_game_player_stats(2013, week = 1, team = "Florida State", category = "passing") -} - -\donttest{ - cfbd_game_records(2018, team = "Notre Dame") - - cfbd_game_records(2013, team = "Florida State") -} - -\donttest{ - cfbd_game_team_stats(2019, team = "LSU") - - cfbd_game_team_stats(2013, team = "Florida State") -} - -} -\keyword{Advanced} -\keyword{Box} -\keyword{Game} -\keyword{Info} -\keyword{Score} -\keyword{Stats} -\keyword{Team} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cfbd_games.R +\name{cfbd_games} +\alias{cfbd_games} +\alias{cfbd_game_info} +\alias{cfbd_calendar} +\alias{cfbd_game_media} +\alias{cfbd_game_box_advanced} +\alias{cfbd_game_player_stats} +\alias{cfbd_game_records} +\alias{cfbd_game_team_stats} +\title{CFBD Games Endpoint} +\source{ +\url{https://api.collegefootballdata.com/games} + +\url{https://api.collegefootballdata.com/calendar} + +\url{https://api.collegefootballdata.com/games/media} + +\url{https://api.collegefootballdata.com/game/box/advanced} + +\url{https://api.collegefootballdata.com/games/players} + +\url{https://api.collegefootballdata.com/records} + +\url{https://api.collegefootballdata.com/games/teams} +} +\usage{ +cfbd_game_info( + year, + week = NULL, + season_type = "regular", + team = NULL, + home_team = NULL, + away_team = NULL, + conference = NULL, + game_id = NULL, + quarter_scores = FALSE, + verbose = FALSE +) + +cfbd_calendar(year, verbose = FALSE) + +cfbd_game_media( + year, + week = NULL, + season_type = "both", + team = NULL, + conference = NULL, + media_type = NULL, + verbose = FALSE +) + +cfbd_game_box_advanced(game_id, long = FALSE, verbose = FALSE) + +cfbd_game_player_stats( + year, + week = NULL, + season_type = "regular", + team = NULL, + conference = NULL, + category = NULL, + game_id = NULL, + verbose = FALSE +) + +cfbd_game_records(year, team = NULL, conference = NULL, verbose = FALSE) + +cfbd_game_team_stats( + year, + week = NULL, + season_type = "regular", + team = NULL, + conference = NULL, + game_id = NULL, + rows_per_team = 1, + verbose = FALSE +) +} +\arguments{ +\item{year}{(\emph{Integer} required): Year, 4 digit format (\emph{YYYY})} + +\item{week}{(\emph{Integer} optional): Week - values range from 1-15, 1-14 for seasons pre-playoff, i.e. 2013 or earlier} + +\item{season_type}{(\emph{String} default: regular): Select Season Type - regular, postseason, or both} + +\item{team}{(\emph{String} optional): D-I Team} + +\item{home_team}{(\emph{String} optional): Home D-I Team} + +\item{away_team}{(\emph{String} optional): Away D-I Team} + +\item{conference}{(\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr +Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr +Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC\cr} + +\item{game_id}{(\emph{Integer} optional): Game ID filter for querying a single game\cr +Can be found using the \code{\link[=cfbd_game_info]{cfbd_game_info()}} function} + +\item{quarter_scores}{(\emph{Logical} default FALSE): This is a parameter to return the +list columns that give the score at each quarter: \code{home_line_scores} and \code{away_line_scores}.\cr +I have defaulted the parameter to false so that you will not have to go to the trouble of dropping it.} + +\item{verbose}{Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function} + +\item{media_type}{(\emph{String} optional): Media type filter: tv, radio, web, ppv, or mobile} + +\item{long}{(\emph{Logical} default \code{FALSE}): Return the data in a long format.} + +\item{category}{(\emph{String} optional): Category filter (e.g defensive)\cr +Offense: passing, receiving, rushing\cr +Defense: defensive, fumbles, interceptions\cr +Special Teams: punting, puntReturns, kicking, kickReturns\cr} + +\item{rows_per_team}{(\emph{Integer} default 1): Both Teams for each game on one or two row(s), Options: 1 or 2} +} +\value{ +\code{\link[=cfbd_game_info]{cfbd_game_info()}} - A data frame with 22 variables: +\describe{ +\item{\code{game_id}: integer.}{Referencing game id.} +\item{\code{season}: integer.}{Season of the game.} +\item{\code{week}: integer.}{Game week.} +\item{\code{season_type}: character.}{Season type of the game.} +\item{\code{start_date}: character.}{Game date.} +\item{\code{start_time_tbd}: logical.}{TRUE/FALSE flag for if the game's start time is to be determined.} +\item{\code{neutral_site}: logical.}{TRUE/FALSE flag for the game taking place at a neutral site.} +\item{\code{conference_game}: logical.}{TRUE/FALSE flag for this game qualifying as a conference game.} +\item{\code{attendance}: integer.}{Reported attendance at the game.} +\item{\code{venue_id}: integer.}{Referencing venue id.} +\item{\code{venue}: character.}{Venue name.} +\item{\code{home_id}: integer.}{Home team referencing id.} +\item{\code{home_team}: character.}{Home team name.} +\item{\code{home_conference}: character.}{Home team conference.} +\item{\code{home_points}: integer.}{Home team points.} +\item{\code{home_post_win_prob}: character.}{Home team post-game win probability.} +\item{\code{away_id}: integer.}{Away team referencing id.} +\item{\code{away_team}: character.}{Away team name.} +\item{\code{away_conference}: character.}{Away team conference.} +\item{\code{away_points}: integer.}{Away team points.} +\item{\code{away_post_win_prob}: character.}{Away team post-game win probability.} +\item{\code{excitement_index}: character.}{Game excitement index.} +} + +\code{\link[=cfbd_calendar]{cfbd_calendar()}} - A data frame with 5 variables: +\describe{ +\item{\code{season}: character.}{Calendar season.} +\item{\code{week}: integer.}{Calendar game week.} +\item{\code{season_type}: character}{Season type of calendar week.} +\item{\code{first_game_start}: character.}{First game start time of the calendar week.} +\item{\code{last_game_start}: character.}{Last game start time of the calendar week.} +} + +\code{\link[=cfbd_game_media]{cfbd_game_media()}} - A data frame with 13 variables: +\describe{ +\item{\code{game_id}: integer.}{Referencing game id.} +\item{\code{season}: integer.}{Season of the game.} +\item{\code{week}: integer.}{Game week.} +\item{\code{season_type}: character.}{Season type of the game.} +\item{\code{start_time}: character.}{Game start time.} +\item{\code{is_start_time_tbd}: logical.}{TRUE/FALSE flag for if the start time is still to be determined.} +\item{\code{home_team}: character.}{Home team of the game.} +\item{\code{home_conference}: character.}{Conference of the home team.} +\item{\code{away_team}: character.}{Away team of the game.} +\item{\code{away_conference}: character.}{Conference of the away team.} +\item{\code{tv}: list.}{TV broadcast networks.} +\item{\code{radio}: logical.}{Radio broadcast networks.} +\item{\code{web}: list.}{Web viewing platforms carrying the game.} +} + +\code{\link[=cfbd_game_box_advanced]{cfbd_game_box_advanced()}} - A data frame with 2 rows and 69 variables: +\describe{ +\item{\code{team}: character.}{.} +\item{\code{plays}: double.}{.} +\item{\code{ppa_overall_total}: double.}{.} +\item{\code{ppa_overall_quarter1}: double.}{.} +\item{\code{ppa_overall_quarter2}: double.}{.} +\item{\code{ppa_overall_quarter3}: double.}{.} +\item{\code{ppa_overall_quarter4}: double.}{.} +\item{\code{ppa_passing_total}: double.}{.} +\item{\code{ppa_passing_quarter1}: double.}{.} +\item{\code{ppa_passing_quarter2}: double.}{.} +\item{\code{ppa_passing_quarter3}: double.}{.} +\item{\code{ppa_passing_quarter4}: double.}{.} +\item{\code{ppa_rushing_total}: double.}{.} +\item{\code{ppa_rushing_quarter1}: double.}{.} +\item{\code{ppa_rushing_quarter2}: double.}{.} +\item{\code{ppa_rushing_quarter3}: double.}{.} +\item{\code{ppa_rushing_quarter4}: double.}{.} +\item{\code{cumulative_ppa_plays}: double.}{.} +\item{\code{cumulative_ppa_overall_total}: double.}{.} +\item{\code{cumulative_ppa_overall_quarter1}: double.}{.} +\item{\code{cumulative_ppa_overall_quarter2}: double.}{.} +\item{\code{cumulative_ppa_overall_quarter3}: double.}{.} +\item{\code{cumulative_ppa_overall_quarter4}: double.}{.} +\item{\code{cumulative_ppa_passing_total}: double.}{.} +\item{\code{cumulative_ppa_passing_quarter1}: double.}{.} +\item{\code{cumulative_ppa_passing_quarter2}: double.}{.} +\item{\code{cumulative_ppa_passing_quarter3}: double.}{.} +\item{\code{cumulative_ppa_passing_quarter4}: double.}{.} +\item{\code{cumulative_ppa_rushing_total}: double.}{.} +\item{\code{cumulative_ppa_rushing_quarter1}: double.}{.} +\item{\code{cumulative_ppa_rushing_quarter2}: double.}{.} +\item{\code{cumulative_ppa_rushing_quarter3}: double.}{.} +\item{\code{cumulative_ppa_rushing_quarter4}: double.}{.} +\item{\code{success_rates_overall_total}: double.}{.} +\item{\code{success_rates_overall_quarter1}: double.}{.} +\item{\code{success_rates_overall_quarter2}: double.}{.} +\item{\code{success_rates_overall_quarter3}: double.}{.} +\item{\code{success_rates_overall_quarter4}: double.}{.} +\item{\code{success_rates_standard_downs_total}: double.}{.} +\item{\code{success_rates_standard_downs_quarter1}: double.}{.} +\item{\code{success_rates_standard_downs_quarter2}: double.}{.} +\item{\code{success_rates_standard_downs_quarter3}: double.}{.} +\item{\code{success_rates_standard_downs_quarter4}: double.}{.} +\item{\code{success_rates_passing_downs_total}: double.}{.} +\item{\code{success_rates_passing_downs_quarter1}: double.}{.} +\item{\code{success_rates_passing_downs_quarter2}: double.}{.} +\item{\code{success_rates_passing_downs_quarter3}: double.}{.} +\item{\code{success_rates_passing_downs_quarter4}: double.}{.} +\item{\code{explosiveness_overall_total}: double.}{.} +\item{\code{explosiveness_overall_quarter1}: double.}{.} +\item{\code{explosiveness_overall_quarter2}: double.}{.} +\item{\code{explosiveness_overall_quarter3}: double.}{.} +\item{\code{explosiveness_overall_quarter4}: double.}{.} +\item{\code{rushing_power_success}: double.}{.} +\item{\code{rushing_stuff_rate}: double.}{.} +\item{\code{rushing_line_yds}: double.}{.} +\item{\code{rushing_line_yd_avg}: double.}{.} +\item{\code{rushing_second_lvl_yds}: double.}{.} +\item{\code{rushing_second_lvl_yd_avg}: double.}{.} +\item{\code{rushing_open_field_yds}: double.}{.} +\item{\code{rushing_open_field_yd_avg}: double.}{.} +\item{\code{havoc_total}: double.}{.} +\item{\code{havoc_front_seven}: double.}{.} +\item{\code{havoc_db}: double.}{.} +\item{\code{scoring_opps_opportunities}: double.}{.} +\item{\code{scoring_opps_points}: double.}{.} +\item{\code{scoring_opps_pts_per_opp}: double.}{.} +\item{\code{field_pos_avg_start}: double.}{.} +\item{\code{field_pos_avg_starting_predicted_pts}: double.}{.} +} + +\code{\link[=cfbd_game_player_stats]{cfbd_game_player_stats()}} - A data frame with 32 variables: +\describe{ +\item{\code{game_id}: integer.}{.} +\item{\code{team}: character.}{.} +\item{\code{conference}: character.}{.} +\item{\code{home_away}: character.}{.} +\item{\code{points}: integer.}{.} +\item{\code{category}: character.}{.} +\item{\code{athlete_id}: character.}{.} +\item{\code{name}: character.}{.} +\item{\code{c_att}: character.}{.} +\item{\code{yds}: double.}{.} +\item{\code{avg}: double.}{.} +\item{\code{td}: double.}{.} +\item{\code{int}: double.}{.} +\item{\code{qbr}: double.}{.} +\item{\code{car}: double.}{.} +\item{\code{long}: double.}{.} +\item{\code{rec}: double.}{.} +\item{\code{no}: double.}{.} +\item{\code{fg}: character.}{.} +\item{\code{pct}: double.}{.} +\item{\code{xp}: character.}{.} +\item{\code{pts}: double.}{.} +\item{\code{tb}: double.}{.} +\item{\code{in_20}: double.}{.} +\item{\code{fum}: double.}{.} +\item{\code{lost}: double.}{.} +\item{\code{tot}: double.}{.} +\item{\code{solo}: double.}{.} +\item{\code{sacks}: double.}{.} +\item{\code{tfl}: double.}{.} +\item{\code{pd}: double.}{.} +\item{\code{qb_hur}: double.}{.} +} + +\code{\link[=cfbd_game_records]{cfbd_game_records()}} - A data frame with 20 variables: +\describe{ +\item{\code{year}: integer.}{.} +\item{\code{team}: character.}{.} +\item{\code{conference}: character.}{.} +\item{\code{division}: character.}{.} +\item{\code{total_games}: integer.}{.} +\item{\code{total_wins}: integer.}{.} +\item{\code{total_losses}: integer.}{.} +\item{\code{total_ties}: integer.}{.} +\item{\code{conference_games}: integer.}{.} +\item{\code{conference_wins}: integer.}{.} +\item{\code{conference_losses}: integer.}{.} +\item{\code{conference_ties}: integer.}{.} +\item{\code{home_games}: integer.}{.} +\item{\code{home_wins}: integer.}{.} +\item{\code{home_losses}: integer.}{.} +\item{\code{home_ties}: integer.}{.} +\item{\code{away_games}: integer.}{.} +\item{\code{away_wins}: integer.}{.} +\item{\code{away_losses}: integer.}{.} +\item{\code{away_ties}: integer.}{.} +} + +\code{\link[=cfbd_game_team_stats]{cfbd_game_team_stats()}} - A data frame with 78 variables: +\describe{ +\item{\code{game_id}: integer.}{.} +\item{\code{school}: character.}{.} +\item{\code{conference}: character.}{.} +\item{\code{home_away}: character.}{.} +\item{\code{points}: integer.}{.} +\item{\code{total_yards}: character.}{.} +\item{\code{net_passing_yards}: character.}{.} +\item{\code{completion_attempts}:character.}{.} +\item{\code{passing_tds}: character.}{.} +\item{\code{yards_per_pass}: character.}{.} +\item{\code{passes_intercepted}: character.}{.} +\item{\code{interception_yards}: character.}{.} +\item{\code{interception_tds}: character.}{.} +\item{\code{rushing_attempts}: character.}{.} +\item{\code{rushing_yards}: character.}{.} +\item{\code{rush_tds}: character.}{.} +\item{\code{yards_per_rush_attempt}: character.}{.} +\item{\code{first_downs}: character.}{.} +\item{\code{third_down_eff}: character.}{.} +\item{\code{fourth_down_eff}: character.}{.} +\item{\code{punt_returns}: character.}{.} +\item{\code{punt_return_yards}: character.}{.} +\item{\code{punt_return_tds}: character.}{.} +\item{\code{kick_return_yards}: character.}{.} +\item{\code{kick_return_tds}: character.}{.} +\item{\code{kick_returns}: character.}{.} +\item{\code{kicking_points}: character.}{.} +\item{\code{fumbles_recovered}: character.}{.} +\item{\code{fumbles_lost}: character.}{.} +\item{\code{total_fumbles}: character.}{.} +\item{\code{tackles}: character.}{.} +\item{\code{tackles_for_loss}: character.}{.} +\item{\code{sacks}: character.}{.} +\item{\code{qb_hurries}: character.}{.} +\item{\code{interceptions}: character.}{.} +\item{\code{passes_deflected}: character.}{.} +\item{\code{turnovers}: character.}{.} +\item{\code{defensive_tds}: character.}{.} +\item{\code{total_penalties_yards}: character.}{.} +\item{\code{possession_time}: character.}{.} +\item{\code{conference_allowed}: character.}{.} +\item{\code{home_away_allowed}: character.}{.} +\item{\code{points_allowed}: integer.}{.} +\item{\code{total_yards_allowed}: character.}{.} +\item{\code{net_passing_yards_allowed}: character.}{.} +\item{\code{completion_attempts_allowed}: character.}{.} +\item{\code{passing_tds_allowed}: character.}{.} +\item{\code{yards_per_pass_allowed}: character.}{.} +\item{\code{passes_intercepted_allowed}: character.}{.} +\item{\code{interception_yards_allowed}: character.}{.} +\item{\code{interception_tds_allowed}: character.}{.} +\item{\code{rushing_attempts_allowed}: character.}{.} +\item{\code{rushing_yards_allowed}: character.}{.} +\item{\code{rush_tds_allowed}: character.}{.} +\item{\code{yards_per_rush_attempt_allowed}: character.}{.} +\item{\code{first_downs_allowed}: character.}{.} +\item{\code{third_down_eff_allowed}: character.}{.} +\item{\code{fourth_down_eff_allowed}: character.}{.} +\item{\code{punt_returns_allowed}: character.}{.} +\item{\code{punt_return_yards_allowed}: character.}{.} +\item{\code{punt_return_tds_allowed}: character.}{.} +\item{\code{kick_return_yards_allowed}: character.}{.} +\item{\code{kick_return_tds_allowed}: character.}{.} +\item{\code{kick_returns_allowed}: character.}{.} +\item{\code{kicking_points_allowed}: character.}{.} +\item{\code{fumbles_recovered_allowed}: character.}{.} +\item{\code{fumbles_lost_allowed}: character.}{.} +\item{\code{total_fumbles_allowed}:character.}{.} +\item{\code{tackles_allowed}:character.}{.} +\item{\code{tackles_for_loss_allowed}: character.}{.} +\item{\code{sacks_allowed}: character.}{.} +\item{\code{qb_hurries_allowed}: character.}{.} +\item{\code{interceptions_allowed}: character.}{.} +\item{\code{passes_deflected_allowed}: character.}{.} +\item{\code{turnovers_allowed}: character.}{.} +\item{\code{defensive_tds_allowed}: character.}{.} +\item{\code{total_penalties_yards_allowed}: character.}{.} +\item{\code{possession_time_allowed}: character.}{.} +} +} +\description{ +Get results, statistics and information for games +\describe{ +\item{\code{cfbd_game_info()}: Get results information from games}{.} +\item{\code{cfbd_calendar()}: Calendar - Returns calendar of weeks by season}{.} +\item{\code{cfbd_game_media()}: Get Game media information (TV, radio, etc)}{.} +\item{\code{cfbd_game_box_advanced()}: Get game advanced box score information}{.} +\item{\code{cfbd_game_player_stats()}: Get results information from games}{.} +\item{\code{cfbd_game_records()}: Get Team records by year}{.} +\item{\code{cfbd_game_team_stats()}: Get Team Statistics by Game}{.} +} +} +\examples{ +\donttest{ + cfbd_game_info(2018, week = 1) + + cfbd_game_info(2018, week = 7, conference = "Ind") + + # 7 OTs LSU @ TAMU + cfbd_game_info(2018, week = 13, team = "Texas A&M", quarter_scores = TRUE) + + cfbd_calendar(2019) + + cfbd_game_media(2019, week = 4, conference = "ACC") + + cfbd_game_box_advanced(game_id = 401114233) + + cfbd_game_player_stats(2018, week = 15, conference = "Ind") + + cfbd_game_player_stats(2013, week = 1, team = "Florida State", category = "passing") + + cfbd_game_records(2018, team = "Notre Dame") + + cfbd_game_records(2013, team = "Florida State") + + cfbd_game_team_stats(2019, team = "LSU") + + cfbd_game_team_stats(2013, team = "Florida State") +} +} +\keyword{Advanced} +\keyword{Box} +\keyword{Game} +\keyword{Info} +\keyword{Score} +\keyword{Stats} +\keyword{Team} diff --git a/man/cfbd_metrics.Rd b/man/cfbd_metrics.Rd index d82c60d2..03286421 100644 --- a/man/cfbd_metrics.Rd +++ b/man/cfbd_metrics.Rd @@ -5,10 +5,10 @@ \alias{cfbd_metrics_ppa_games} \alias{cfbd_metrics_ppa_players_games} \alias{cfbd_metrics_ppa_players_season} -\alias{cfbd_metrics_ppa_predicted} \alias{cfbd_metrics_ppa_teams} \alias{cfbd_metrics_wp_pregame} \alias{cfbd_metrics_wp} +\alias{cfbd_metrics_ppa_predicted} \title{CFBD Metrics Endpoint} \source{ \url{https://api.collegefootballdata.com/ppa/players/games} @@ -31,15 +31,6 @@ cfbd_metrics_ppa_games( verbose = FALSE ) -cfbd_metrics_ppa_games( - year, - week = NULL, - team = NULL, - conference = NULL, - excl_garbage_time = FALSE, - verbose = FALSE -) - cfbd_metrics_ppa_players_games( year = NULL, week = NULL, @@ -106,7 +97,7 @@ Position Group - options include:\cr }} \item{athlete_id}{(\emph{Integer} optional): Athlete ID filter for querying a single athlete\cr -Can be found using the \code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_player_info()}} function.} +Can be found using the \code{\link[=cfbd_player_info]{cfbd_player_info()}} function.} \item{threshold}{(\emph{Integer} optional): Minimum threshold of plays.} @@ -117,181 +108,147 @@ Can be found using the \code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_pla \item{season_type}{(\emph{String} default regular): Select Season Type: regular or postseason} \item{game_id}{(\emph{Integer} required): Game ID filter for querying a single game\cr -Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function} +Can be found using the \code{\link[=cfbd_game_info]{cfbd_game_info()}} function} } \value{ -\code{\link[cfbfastR:cfbd_metrics_ppa_games]{cfbfastR::cfbd_metrics_ppa_games()}} - A data frame with 18 variables: -\describe{ -\item{\code{game_id}}{integer.} -\item{\code{season}}{integer.} -\item{\code{week}}{integer.} -\item{\code{conference}}{character.} -\item{\code{team}}{character.} -\item{\code{opponent}}{character.} -\item{\code{off_overall}}{character.} -\item{\code{off_passing}}{character.} -\item{\code{off_rushing}}{character.} -\item{\code{off_first_down}}{character.} -\item{\code{off_second_down}}{character.} -\item{\code{off_third_down}}{character.} -\item{\code{def_overall}}{character.} -\item{\code{def_passing}}{character.} -\item{\code{def_rushing}}{character.} -\item{\code{def_first_down}}{character.} -\item{\code{def_second_down}}{character.} -\item{\code{def_third_down}}{character.} -} - -\code{\link[cfbfastR:cfbd_metrics_ppa_games]{cfbfastR::cfbd_metrics_ppa_games()}} - A data frame with 18 variables: +\code{\link[=cfbd_metrics_ppa_games]{cfbd_metrics_ppa_games()}} - A data frame with 18 variables: \describe{ -\item{\code{game_id}}{integer.} -\item{\code{season}}{integer.} -\item{\code{week}}{integer.} -\item{\code{conference}}{character.} -\item{\code{team}}{character.} -\item{\code{opponent}}{character.} -\item{\code{off_overall}}{character.} -\item{\code{off_passing}}{character.} -\item{\code{off_rushing}}{character.} -\item{\code{off_first_down}}{character.} -\item{\code{off_second_down}}{character.} -\item{\code{off_third_down}}{character.} -\item{\code{def_overall}}{character.} -\item{\code{def_passing}}{character.} -\item{\code{def_rushing}}{character.} -\item{\code{def_first_down}}{character.} -\item{\code{def_second_down}}{character.} -\item{\code{def_third_down}}{character.} +\item{\code{game_id}: integer.}{Referencing game id.} +\item{\code{season}: integer.}{Season of the game.} +\item{\code{week}: integer.}{Game week of the season.} +\item{\code{conference}: character.}{Conference of the team.} +\item{\code{team}: character.}{Team name.} +\item{\code{opponent}: character.}{Team Opponent.} +\item{\code{off_overall}: character.}{Offense overall predicted points added (PPA).} +\item{\code{off_passing}: character.}{Offense passing predicted points added (PPA).} +\item{\code{off_rushing}: character.}{Offense rushing predicted points added (PPA).} +\item{\code{off_first_down}: character.}{Offense 1st down predicted points added (PPA).} +\item{\code{off_second_down}: character.}{Offense 2nd down predicted points added (PPA).} +\item{\code{off_third_down}: character.}{Offense 3rd down predicted points added (PPA).} +\item{\code{def_overall}: character.}{Defense overall predicted points added (PPA).} +\item{\code{def_passing}: character.}{Defense passing predicted points added (PPA).} +\item{\code{def_rushing}: character.}{Defense rushing predicted points added (PPA).} +\item{\code{def_first_down}: character.}{Defense 1st down predicted points added (PPA).} +\item{\code{def_second_down}: character.}{Defense 2nd down predicted points added (PPA).} +\item{\code{def_third_down}: character.}{Defense 3rd down predicted points added (PPA).} } -\code{\link[cfbfastR:cfbd_metrics_ppa_players_games]{cfbfastR::cfbd_metrics_ppa_players_games()}} - A data frame with 9 variables: +\code{\link[=cfbd_metrics_ppa_players_games]{cfbd_metrics_ppa_players_games()}} - A data frame with 9 variables: \describe{ -\item{\code{season}}{integer.} -\item{\code{week}}{integer.} -\item{\code{name}}{character.} -\item{\code{position}}{character.} -\item{\code{team}}{character.} -\item{\code{opponent}}{character.} -\item{\code{avg_PPA_all}}{double.} -\item{\code{avg_PPA_pass}}{double.} -\item{\code{avg_PPA_rush}}{double.} +\item{\code{season}: integer.}{Season of the game.} +\item{\code{week}: integer.}{Game week of the season.} +\item{\code{name}: character.}{Athlete name.} +\item{\code{position}: character.}{Athlete position.} +\item{\code{team}: character.}{Team name.} +\item{\code{opponent}: character.}{Team Opponent name.} +\item{\code{avg_PPA_all}: double.}{Average overall predicted points added (PPA).} +\item{\code{avg_PPA_pass}: double.}{Average passing predicted points added (PPA).} +\item{\code{avg_PPA_rush}: double.}{Average rushing predicted points added (PPA).} } -\code{\link[cfbfastR:cfbd_metrics_ppa_players_season]{cfbfastR::cfbd_metrics_ppa_players_season()}} - A data frame with 23 variables: +\code{\link[=cfbd_metrics_ppa_players_season]{cfbd_metrics_ppa_players_season()}} - A data frame with 23 variables: \describe{ -\item{\code{season}}{integer.} -\item{\code{id}}{character.} -\item{\code{name}}{character.} -\item{\code{position}}{character.} -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{countable_plays}}{integer.} -\item{\code{avg_PPA_all}}{double.} -\item{\code{avg_PPA_pass}}{double.} -\item{\code{avg_PPA_rush}}{double.} -\item{\code{avg_PPA_first_down}}{double.} -\item{\code{avg_PPA_second_down}}{double.} -\item{\code{avg_PPA_third_down}}{double.} -\item{\code{avg_PPA_standard_downs}}{double.} -\item{\code{avg_PPA_passing_downs}}{double.} -\item{\code{total_PPA_all}}{double.} -\item{\code{total_PPA_pass}}{double.} -\item{\code{total_PPA_rush}}{double.} -\item{\code{total_PPA_first_down}}{double.} -\item{\code{total_PPA_second_down}}{double.} -\item{\code{total_PPA_third_down}}{double.} -\item{\code{total_PPA_standard_downs}}{double.} -\item{\code{total_PPA_passing_downs}}{double.} +\item{\code{season}: integer.}{Season.} +\item{\code{athlete_id}: character.}{Athlete referencing id.} +\item{\code{name}: character.}{Athlete name.} +\item{\code{position}: character.}{Athlete Position.} +\item{\code{team}: character.}{Team name.} +\item{\code{conference}: character.}{Team conference.} +\item{\code{countable_plays}: integer.}{Number of plays which can be counted.} +\item{\code{avg_PPA_all}: double.}{Average overall predicted points added (PPA).} +\item{\code{avg_PPA_pass}: double.}{Average passing predicted points added (PPA).} +\item{\code{avg_PPA_rush}: double.}{Average rushing predicted points added (PPA).} +\item{\code{avg_PPA_first_down}: double.}{Average 1st down predicted points added (PPA).} +\item{\code{avg_PPA_second_down}: double.}{Average 2nd down predicted points added (PPA).} +\item{\code{avg_PPA_third_down}: double.}{Average 3rd down predicted points added (PPA).} +\item{\code{avg_PPA_standard_downs}: double.}{Average standard down predicted points added (PPA).} +\item{\code{avg_PPA_passing_downs}: double.}{Average passing down predicted points added (PPA).} +\item{\code{total_PPA_all}: double.}{Total overall predicted points added (PPA).} +\item{\code{total_PPA_pass}: double.}{Total passing predicted points added (PPA).} +\item{\code{total_PPA_rush}: double.}{Total rushing predicted points added (PPA).} +\item{\code{total_PPA_first_down}: double.}{Total 1st down predicted points added (PPA).} +\item{\code{total_PPA_second_down}: double.}{Total 2nd down predicted points added (PPA).} +\item{\code{total_PPA_third_down}: double.}{Total 3rd down predicted points added (PPA).} +\item{\code{total_PPA_standard_downs}: double.}{Total standard down predicted points added (PPA).} +\item{\code{total_PPA_passing_downs}: double.}{Total passing down predicted points added (PPA).} } -\code{\link[cfbfastR:cfbd_metrics_ppa_predicted]{cfbfastR::cfbd_metrics_ppa_predicted()}} - A data frame with 2 variables: +\code{\link[=cfbd_metrics_ppa_predicted]{cfbd_metrics_ppa_predicted()}} - A data frame with 2 variables: \describe{ -\item{\code{yard_line}}{integer.} -\item{\code{predicted_points}}{character.} +\item{\code{yard_line}: integer.}{Yards to goal} +\item{\code{predicted_points}: character.}{Predicted points at in that down-distance-yardline scenario} } -\code{\link[cfbfastR:cfbd_metrics_ppa_teams]{cfbfastR::cfbd_metrics_ppa_teams()}} - A data frame with 21 variables: +\code{\link[=cfbd_metrics_ppa_teams]{cfbd_metrics_ppa_teams()}} - A data frame with 21 variables: \describe{ -\item{\code{season}}{integer.} -\item{\code{conference}}{character.} -\item{\code{team}}{character.} -\item{\code{off_overall}}{character.} -\item{\code{off_passing}}{character.} -\item{\code{off_rushing}}{character.} -\item{\code{off_first_down}}{character.} -\item{\code{off_second_down}}{character.} -\item{\code{off_third_down}}{character.} -\item{\code{off_cumulative_total}}{character.} -\item{\code{off_cumulative_passing}}{character.} -\item{\code{off_cumulative_rushing}}{character.} -\item{\code{def_overall}}{character.} -\item{\code{def_passing}}{character.} -\item{\code{def_rushing}}{character.} -\item{\code{def_first_down}}{character.} -\item{\code{def_second_down}}{character.} -\item{\code{def_third_down}}{character.} -\item{\code{def_cumulative_total}}{character.} -\item{\code{def_cumulative_passing}}{character.} -\item{\code{def_cumulative_rushing}}{character.} +\item{\code{season}: integer.}{.} +\item{\code{conference}: character.}{.} +\item{\code{team}: character.}{.} +\item{\code{off_overall}: character.}{Offense overall predicted points added (PPA).} +\item{\code{off_passing}: character.}{Offense passing predicted points added (PPA).} +\item{\code{off_rushing}: character.}{Offense rushing predicted points added (PPA).} +\item{\code{off_first_down}: character.}{Offense 1st down predicted points added (PPA).} +\item{\code{off_second_down}: character.}{Offense 2nd down predicted points added (PPA).} +\item{\code{off_third_down}: character.}{Offense 3rd down predicted points added (PPA).} +\item{\code{off_cumulative_total}: character.}{Offense cumulative total predicted points added (PPA).} +\item{\code{off_cumulative_passing}: character.}{Offense cumulative total passing predicted points added (PPA).} +\item{\code{off_cumulative_rushing}: character.}{Offense cumulative total rushing predicted points added (PPA).} +\item{\code{def_overall}: character.}{Defense overall predicted points added (PPA).} +\item{\code{def_passing}: character.}{Defense passing predicted points added (PPA).} +\item{\code{def_rushing}: character.}{Defense rushing predicted points added (PPA).} +\item{\code{def_first_down}: character.}{Defense 1st down predicted points added (PPA).} +\item{\code{def_second_down}: character.}{Defense 2nd down predicted points added (PPA).} +\item{\code{def_third_down}: character.}{Defense 3rd down predicted points added (PPA).} +\item{\code{def_cumulative_total}: character.}{Defense cumulative total predicted points added (PPA).} +\item{\code{def_cumulative_passing}: character.}{Defense cumulative total passing predicted points added (PPA).} +\item{\code{def_cumulative_rushing}: character.}{Defense cumulative total rushing predicted points added (PPA).} } -\code{\link[cfbfastR:cfbd_metrics_wp_pregame]{cfbfastR::cfbd_metrics_wp_pregame()}} - A data frame with 9 variables: +\code{\link[=cfbd_metrics_wp_pregame]{cfbd_metrics_wp_pregame()}} - A data frame with 9 variables: \describe{ -\item{\code{season}}{integer.} -\item{\code{season_type}}{character.} -\item{\code{week}}{integer.} -\item{\code{game_id}}{integer.} -\item{\code{home_team}}{character.} -\item{\code{away_team}}{character.} -\item{\code{spread}}{integer.} -\item{\code{home_win_prob}}{double.} -\item{\code{away_win_prob}}{double.} +\item{\code{season}: integer.}{Season of game.} +\item{\code{season_type}: character.}{Season type of game.} +\item{\code{week}: integer.}{Game week of the season.} +\item{\code{game_id}: integer.}{Referencing game id.} +\item{\code{home_team}: character.}{Home team name.} +\item{\code{away_team}: character.}{Away team name.} +\item{\code{spread}: integer.}{Betting line provider spread.} +\item{\code{home_win_prob}: double.}{Home win probability - pre-game prediction.} +\item{\code{away_win_prob}: double.}{Away win probability - pre-game prediction.} } -\code{\link[cfbfastR:cfbd_metrics_wp]{cfbfastR::cfbd_metrics_wp()}} - A data frame with 16 variables: +\code{\link[=cfbd_metrics_wp]{cfbd_metrics_wp()}} - A data frame with 16 variables: \describe{ -\item{\code{play_id}}{character.} -\item{\code{play_text}}{character.} -\item{\code{home_id}}{integer.} -\item{\code{home}}{character.} -\item{\code{away_id}}{integer.} -\item{\code{away}}{character.} -\item{\code{spread}}{character.} -\item{\code{home_ball}}{logical.} -\item{\code{home_score}}{integer.} -\item{\code{away_score}}{integer.} -\item{\code{down}}{integer.} -\item{\code{distance}}{integer.} -\item{\code{home_win_prob}}{character.} -\item{\code{away_win_prob}}{double.} -\item{\code{play_number}}{integer.} -\item{\code{yard_line}}{integer.} +\item{\code{play_id}: character.}{Play referencing id.} +\item{\code{play_text}: character.}{A text description of the play.} +\item{\code{home_id}: integer.}{Home team referencing id.} +\item{\code{home}: character.}{Home team name.} +\item{\code{away_id}: integer.}{Away team referencing id.} +\item{\code{away}: character.}{Away team name.} +\item{\code{spread}: character.}{Betting lines provider spread.} +\item{\code{home_ball}: logical.}{Home team has the ball.} +\item{\code{home_score}: integer.}{Home team score.} +\item{\code{away_score}: integer.}{Away team score.} +\item{\code{down}: integer.}{Down of the play.} +\item{\code{distance}: integer.}{Distance to the sticks (to 1st down marker of goal-line in goal-to-go situations).} +\item{\code{home_win_prob}: character.}{Home team win probability.} +\item{\code{away_win_prob}: double.}{Away team win probability.} +\item{\code{play_number}: integer.}{Game play number.} +\item{\code{yard_line}: integer.}{Yard line of the play (0-100 yards).} } } \description{ -CFBD Metrics Endpoint - -Get team game averages for Predicted Points Added (PPA) - -Get team game averages for Predicted Points Added (PPA) - -Get player game averages for Predicted Points Added (PPA) - -Get player season averages for Predicted Points Added (PPA) - -Calculate Predicted Points using Down and Distance - -Get team averages for Predicted Points Added (PPA) - -Get Pre-game Win Probability Data from API - -Get win probability chart data from API +\describe{ +\item{\code{cfbd_metrics_ppa_games()}:}{Get team game averages for Predicted Points Added (PPA).} +\item{\code{cfbd_metrics_ppa_players_games()}:}{Get player game averages for Predicted Points Added (PPA).} +\item{\code{cfbd_metrics_ppa_players_season()}:}{Get player season averages for Predicted Points Added (PPA).} +\item{\code{cfbd_metrics_ppa_predicted()}:}{Calculate Predicted Points using Down and Distance.} +\item{\code{cfbd_metrics_ppa_teams()}:}{Get team averages for Predicted Points Added (PPA).} +\item{\code{cfbd_metrics_wp_pregame()}:}{Get Pre-game Win Probability Data from CFBD API.} +\item{\code{cfbd_metrics_wp()}:}{Get win probability chart data from CFBD API.} } -\examples{ -\donttest{ - cfbd_metrics_ppa_games(year = 2019, team = "TCU") } - +\examples{ \donttest{ cfbd_metrics_ppa_games(year = 2019, team = "TCU") } diff --git a/man/cfbd_pbp_data.Rd b/man/cfbd_pbp_data.Rd index 48414729..eaa7b605 100644 --- a/man/cfbd_pbp_data.Rd +++ b/man/cfbd_pbp_data.Rd @@ -2,6 +2,8 @@ % Please edit documentation in R/cfbd_pbp_data.R \name{cfbd_pbp_data} \alias{cfbd_pbp_data} +\alias{play-by-play} +\alias{pbp_data} \title{CFBD Play by Play Data} \source{ \url{https://api.collegefootballdata.com/plays} @@ -27,7 +29,7 @@ cfbd_pbp_data( \item{team}{Select team name (example: Texas, Texas A&M, Clemson)} -\item{play_type}{Select play type (example: see the \code{\link[cfbfastR:cfbd_play_type_df]{cfbd_play_type_df}})} +\item{play_type}{Select play type (example: see the \link{cfbd_play_type_df})} \item{epa_wpa}{Logical parameter (TRUE/FALSE) to return the Expected Points Added/Win Probability Added variables} @@ -38,362 +40,360 @@ cfbd_pbp_data( \value{ A data frame with 351 variables: \describe{ -\item{\code{year}}{double.} -\item{\code{week}}{double.} -\item{\code{id_play}}{character.} -\item{\code{game_id}}{integer.} -\item{\code{game_play_number}}{double.} -\item{\code{half_play_number}}{double.} -\item{\code{pos_team}}{character.} -\item{\code{def_pos_team}}{character.} -\item{\code{half}}{integer.} -\item{\code{period}}{integer.} -\item{\code{clock.minutes}}{integer.} -\item{\code{clock.seconds}}{integer.} -\item{\code{play_type}}{character.} -\item{\code{play_text}}{character.} -\item{\code{down}}{double.} -\item{\code{distance}}{double.} -\item{\code{yards_to_goal}}{double.} -\item{\code{yards_gained}}{double.} -\item{\code{penalty_1st_conv}}{logical.} -\item{\code{new_series}}{double.} -\item{\code{change_of_pos_team}}{double.} -\item{\code{lag_change_of_pos_team}}{double.} -\item{\code{orig_play_type}}{character.} -\item{\code{lead_play_type}}{character.} -\item{\code{lag_play_type}}{character.} -\item{\code{lag_play_type2}}{character.} -\item{\code{lag_play_type3}}{character.} -\item{\code{row}}{integer.} -\item{\code{drive_play_number}}{double.} -\item{\code{drive_event_number}}{double.} -\item{\code{lag_play_text}}{character.} -\item{\code{lag_play_text2}}{character.} -\item{\code{lead_play_text}}{character.} -\item{\code{firstD_by_kickoff}}{double.} -\item{\code{firstD_by_poss}}{double.} -\item{\code{firstD_by_penalty}}{double.} -\item{\code{firstD_by_yards}}{double.} -\item{\code{lag_first_by_penalty}}{double.} -\item{\code{lag_first_by_penalty2}}{double.} -\item{\code{lag_first_by_yards}}{double.} -\item{\code{lag_first_by_yards2}}{double.} -\item{\code{first_by_penalty}}{double.} -\item{\code{first_by_yards}}{double.} -\item{\code{play_after_turnover}}{double.} -\item{\code{lag_change_of_poss}}{double.} -\item{\code{lag_kickoff_play}}{double.} -\item{\code{lag_punt}}{double.} -\item{\code{lag_scoring_play}}{double.} -\item{\code{lag_turnover_vec}}{double.} -\item{\code{lag_downs_turnover}}{double.} -\item{\code{lag_defense_score_play}}{double.} -\item{\code{EPA}}{double.} -\item{\code{ep_before}}{double.} -\item{\code{ep_after}}{double.} -\item{\code{wpa}}{double.} -\item{\code{wp_before}}{double.} -\item{\code{wp_after}}{double.} -\item{\code{def_wp_before}}{double.} -\item{\code{def_wp_after}}{double.} -\item{\code{penalty_detail}}{character.} -\item{\code{yds_penalty}}{double.} -\item{\code{downs_turnover}}{double.} -\item{\code{turnover}}{double.} -\item{\code{pos_score_diff_start}}{double.} -\item{\code{pos_score_pts}}{double.} -\item{\code{pos_team_score}}{integer.} -\item{\code{def_pos_team_score}}{integer.} -\item{\code{log_ydstogo}}{double.} -\item{\code{ExpScoreDiff}}{double.} -\item{\code{ExpScoreDiff_Time_Ratio}}{double.} -\item{\code{half_clock.minutes}}{double.} -\item{\code{TimeSecsRem}}{double.} -\item{\code{adj_TimeSecsRem}}{double.} -\item{\code{Goal_To_Go}}{logical.} -\item{\code{Under_two}}{logical.} -\item{\code{home}}{character.} -\item{\code{away}}{character.} -\item{\code{home_wp_before}}{double.} -\item{\code{away_wp_before}}{double.} -\item{\code{home_wp_after}}{double.} -\item{\code{away_wp_after}}{double.} -\item{\code{end_of_half}}{double.} -\item{\code{pos_team_receives_2H_kickoff}}{double.} -\item{\code{lead_pos_team}}{character.} -\item{\code{lag_pos_team}}{character.} -\item{\code{Under_three}}{logical.} -\item{\code{down_end}}{integer.} -\item{\code{distance_end}}{double.} -\item{\code{log_ydstogo_end}}{double.} -\item{\code{yards_to_goal_end}}{double.} -\item{\code{TimeSecsRem_end}}{double.} -\item{\code{Goal_To_Go_end}}{logical.} -\item{\code{Under_two_end}}{logical.} -\item{\code{def_EPA}}{double.} -\item{\code{offense_score_play}}{double.} -\item{\code{defense_score_play}}{double.} -\item{\code{ppa}}{character.} -\item{\code{yard_line}}{integer.} -\item{\code{scoring}}{logical.} -\item{\code{pos_team_timeouts_rem_before}}{double.} -\item{\code{def_pos_team_timeouts_rem_before}}{double.} -\item{\code{pos_team_timeouts}}{integer.} -\item{\code{def_pos_team_timeouts}}{integer.} -\item{\code{pos_score_diff}}{integer.} -\item{\code{pos_score_diff_start_end}}{double.} -\item{\code{offense_play}}{character.} -\item{\code{defense_play}}{character.} -\item{\code{offense_receives_2H_kickoff}}{double.} -\item{\code{change_of_poss}}{double.} -\item{\code{score_pts}}{double.} -\item{\code{score_diff_start}}{double.} -\item{\code{score_diff}}{integer.} -\item{\code{offense_score}}{integer.} -\item{\code{defense_score}}{integer.} -\item{\code{offense_conference}}{character.} -\item{\code{defense_conference}}{character.} -\item{\code{off_timeout_called}}{double.} -\item{\code{def_timeout_called}}{double.} -\item{\code{offense_timeouts}}{integer.} -\item{\code{defense_timeouts}}{integer.} -\item{\code{off_timeouts_rem_before}}{double.} -\item{\code{def_timeouts_rem_before}}{double.} -\item{\code{rusher_player_name}}{character.} -\item{\code{yds_rushed}}{double.} -\item{\code{passer_player_name}}{character.} -\item{\code{receiver_player_name}}{character.} -\item{\code{yds_receiving}}{double.} -\item{\code{yds_sacked}}{double.} -\item{\code{sack_players}}{character.} -\item{\code{sack_player_name}}{character.} -\item{\code{sack_player_name2}}{character.} -\item{\code{pass_breakup_player_name}}{character.} -\item{\code{interception_player_name}}{character.} -\item{\code{yds_int_return}}{double.} -\item{\code{fumble_player_name}}{character.} -\item{\code{fumble_forced_player_name}}{character.} -\item{\code{fumble_recovered_player_name}}{character.} -\item{\code{yds_fumble_return}}{double.} -\item{\code{punter_player_name}}{character.} -\item{\code{yds_punted}}{double.} -\item{\code{punt_returner_player_name}}{character.} -\item{\code{yds_punt_return}}{double.} -\item{\code{yds_punt_gained}}{double.} -\item{\code{punt_block_player_name}}{character.} -\item{\code{punt_block_return_player_name}}{character.} -\item{\code{fg_kicker_player_name}}{character.} -\item{\code{yds_fg}}{double.} -\item{\code{fg_block_player_name}}{character.} -\item{\code{fg_return_player_name}}{character.} -\item{\code{kickoff_player_name}}{character.} -\item{\code{yds_kickoff}}{double.} -\item{\code{kickoff_returner_player_name}}{character.} -\item{\code{yds_kickoff_return}}{double.} -\item{\code{new_id}}{double.} -\item{\code{orig_drive_number}}{integer.} -\item{\code{drive_number}}{integer.} -\item{\code{drive_result_detailed}}{character.} -\item{\code{new_drive_pts}}{double.} -\item{\code{drive_id}}{double.} -\item{\code{drive_result}}{character.} -\item{\code{drive_start_yards_to_goal}}{double.} -\item{\code{drive_end_yards_to_goal}}{integer.} -\item{\code{drive_yards}}{integer.} -\item{\code{drive_scoring}}{double.} -\item{\code{drive_pts}}{double.} -\item{\code{drive_start_period}}{integer.} -\item{\code{drive_end_period}}{integer.} -\item{\code{drive_time_minutes_start}}{integer.} -\item{\code{drive_time_seconds_start}}{integer.} -\item{\code{drive_time_minutes_end}}{integer.} -\item{\code{drive_time_seconds_end}}{integer.} -\item{\code{drive_time_minutes_elapsed}}{integer.} -\item{\code{drive_time_seconds_elapsed}}{integer.} -\item{\code{drive_numbers}}{double.} -\item{\code{number_of_drives}}{double.} -\item{\code{pts_scored}}{double.} -\item{\code{drive_result_detailed_flag}}{character.} -\item{\code{drive_result2}}{character.} -\item{\code{drive_num}}{double.} -\item{\code{lag_drive_result_detailed}}{character.} -\item{\code{lead_drive_result_detailed}}{character.} -\item{\code{lag_new_drive_pts}}{double.} -\item{\code{id_drive}}{character.} -\item{\code{rush}}{double.} -\item{\code{rush_td}}{double.} -\item{\code{pass}}{double.} -\item{\code{pass_td}}{double.} -\item{\code{completion}}{double.} -\item{\code{pass_attempt}}{double.} -\item{\code{target}}{double.} -\item{\code{sack_vec}}{double.} -\item{\code{sack}}{double.} -\item{\code{int}}{double.} -\item{\code{int_td}}{double.} -\item{\code{turnover_vec}}{double.} -\item{\code{turnover_vec_lag}}{double.} -\item{\code{turnover_indicator}}{double.} -\item{\code{kickoff_play}}{double.} -\item{\code{receives_2H_kickoff}}{double.} -\item{\code{missing_yard_flag}}{logical.} -\item{\code{scoring_play}}{double.} -\item{\code{td_play}}{double.} -\item{\code{touchdown}}{double.} -\item{\code{safety}}{double.} -\item{\code{fumble_vec}}{double.} -\item{\code{kickoff_tb}}{double.} -\item{\code{kickoff_onside}}{double.} -\item{\code{kickoff_oob}}{double.} -\item{\code{kickoff_fair_catch}}{double.} -\item{\code{kickoff_downed}}{double.} -\item{\code{kickoff_safety}}{double.} -\item{\code{kick_play}}{double.} -\item{\code{punt}}{double.} -\item{\code{punt_play}}{double.} -\item{\code{punt_tb}}{double.} -\item{\code{punt_oob}}{double.} -\item{\code{punt_fair_catch}}{double.} -\item{\code{punt_downed}}{double.} -\item{\code{punt_safety}}{double.} -\item{\code{punt_blocked}}{double.} -\item{\code{penalty_safety}}{double.} -\item{\code{fg_inds}}{double.} -\item{\code{fg_made}}{logical.} -\item{\code{fg_make_prob}}{double.} -\item{\code{home_EPA}}{double.} -\item{\code{away_EPA}}{double.} -\item{\code{home_EPA_rush}}{double.} -\item{\code{away_EPA_rush}}{double.} -\item{\code{home_EPA_pass}}{double.} -\item{\code{away_EPA_pass}}{double.} -\item{\code{total_home_EPA}}{double.} -\item{\code{total_away_EPA}}{double.} -\item{\code{total_home_EPA_rush}}{double.} -\item{\code{total_away_EPA_rush}}{double.} -\item{\code{total_home_EPA_pass}}{double.} -\item{\code{total_away_EPA_pass}}{double.} -\item{\code{net_home_EPA}}{double.} -\item{\code{net_away_EPA}}{double.} -\item{\code{net_home_EPA_rush}}{double.} -\item{\code{net_away_EPA_rush}}{double.} -\item{\code{net_home_EPA_pass}}{double.} -\item{\code{net_away_EPA_pass}}{double.} -\item{\code{success}}{double.} -\item{\code{epa_success}}{double.} -\item{\code{rz_play}}{double.} -\item{\code{scoring_opp}}{double.} -\item{\code{middle_8}}{logical.} -\item{\code{stuffed_run}}{double.} -\item{\code{spread}}{double.} -\item{\code{formatted_spread}}{character.} -\item{\code{No_Score_before}}{double.} -\item{\code{FG_before}}{double.} -\item{\code{Opp_FG_before}}{double.} -\item{\code{Opp_Safety_before}}{double.} -\item{\code{Opp_TD_before}}{double.} -\item{\code{Safety_before}}{double.} -\item{\code{TD_before}}{double.} -\item{\code{No_Score_after}}{double.} -\item{\code{FG_after}}{double.} -\item{\code{Opp_FG_after}}{double.} -\item{\code{Opp_Safety_after}}{double.} -\item{\code{Opp_TD_after}}{double.} -\item{\code{Safety_after}}{double.} -\item{\code{TD_after}}{double.} -\item{\code{penalty_flag}}{logical.} -\item{\code{penalty_declined}}{logical.} -\item{\code{penalty_no_play}}{logical.} -\item{\code{penalty_offset}}{logical.} -\item{\code{penalty_text}}{logical.} -\item{\code{penalty_play_text}}{character.} -\item{\code{lead_wp_before2}}{double.} -\item{\code{wpa_half_end}}{double.} -\item{\code{wpa_base}}{double.} -\item{\code{wpa_base_nxt}}{double.} -\item{\code{wpa_change}}{double.} -\item{\code{wpa_change_nxt}}{double.} -\item{\code{wpa_base_ind}}{double.} -\item{\code{wpa_base_nxt_ind}}{double.} -\item{\code{wpa_change_ind}}{double.} -\item{\code{wpa_change_nxt_ind}}{double.} -\item{\code{lead_wp_before}}{double.} -\item{\code{lead_pos_team2}}{character.} -\item{\code{lag_change_of_pos_team2}}{double.} -\item{\code{lag_punt2}}{double.} -\item{\code{lag_score_diff}}{double.} -\item{\code{lag_offense_play}}{character.} -\item{\code{lead_offense_play}}{character.} -\item{\code{lead_offense_play2}}{character.} -\item{\code{lag_pos_score_diff}}{double.} -\item{\code{lag_off_timeouts}}{double.} -\item{\code{lag_def_timeouts}}{double.} -\item{\code{lag_TimeSecsRem2}}{double.} -\item{\code{lag_TimeSecsRem}}{double.} -\item{\code{lead_TimeSecsRem}}{double.} -\item{\code{lead_TimeSecsRem2}}{double.} -\item{\code{lag_yards_to_goal2}}{integer.} -\item{\code{lag_yards_to_goal}}{integer.} -\item{\code{lead_yards_to_goal}}{double.} -\item{\code{lead_yards_to_goal2}}{integer.} -\item{\code{lag_down2}}{double.} -\item{\code{lag_down}}{double.} -\item{\code{lead_down}}{double.} -\item{\code{lead_down2}}{double.} -\item{\code{lead_distance}}{double.} -\item{\code{lead_distance2}}{integer.} -\item{\code{lead_play_type2}}{character.} -\item{\code{lead_play_type3}}{character.} -\item{\code{lag_ep_before3}}{double.} -\item{\code{lag_ep_before2}}{double.} -\item{\code{lag_ep_before}}{double.} -\item{\code{lead_ep_before}}{double.} -\item{\code{lead_ep_before2}}{double.} -\item{\code{lag_ep_after}}{double.} -\item{\code{lag_ep_after2}}{double.} -\item{\code{lag_ep_after3}}{double.} -\item{\code{lead_ep_after}}{double.} -\item{\code{lead_ep_after2}}{double.} -\item{\code{play_number}}{integer.} -\item{\code{over_under}}{double.} -\item{\code{event}}{double.} -\item{\code{game_event_number}}{double.} -\item{\code{game_row_number}}{integer.} -\item{\code{half_event}}{double.} -\item{\code{half_event_number}}{double.} -\item{\code{half_row_number}}{integer.} -\item{\code{lag_distance3}}{integer.} -\item{\code{lag_distance2}}{integer.} -\item{\code{lag_distance}}{integer.} -\item{\code{lag_yards_gained3}}{integer.} -\item{\code{lag_yards_gained2}}{integer.} -\item{\code{lag_yards_gained}}{integer.} -\item{\code{lead_yards_gained}}{integer.} -\item{\code{lead_yards_gained2}}{integer.} -\item{\code{lag_play_text3}}{character.} -\item{\code{lead_play_text2}}{character.} -\item{\code{lead_play_text3}}{character.} -\item{\code{lag_change_of_poss2}}{double.} -\item{\code{lag_change_of_poss3}}{double.} -\item{\code{lag_change_of_pos_team3}}{double.} -\item{\code{lag_kickoff_play2}}{double.} -\item{\code{lag_kickoff_play3}}{double.} -\item{\code{lag_punt3}}{double.} -\item{\code{lag_scoring_play2}}{double.} -\item{\code{lag_scoring_play3}}{double.} -\item{\code{lag_turnover_vec2}}{double.} -\item{\code{lag_turnover_vec3}}{double.} -\item{\code{lag_downs_turnover2}}{double.} -\item{\code{lag_downs_turnover3}}{double.} -\item{\code{drive_event}}{double.} -\item{\code{lag_first_by_penalty3}}{double.} -\item{\code{lag_first_by_yards3}}{double.} +\item{\code{year}: double.}{.} +\item{\code{week}: double.}{.} +\item{\code{id_play}: character.}{.} +\item{\code{game_id}: integer.}{.} +\item{\code{game_play_number}: double.}{.} +\item{\code{half_play_number}: double.}{.} +\item{\code{pos_team}: character.}{.} +\item{\code{def_pos_team}: character.}{.} +\item{\code{half}: integer.}{.} +\item{\code{period}: integer.}{.} +\item{\code{clock.minutes}: integer.}{.} +\item{\code{clock.seconds}: integer.}{.} +\item{\code{play_type}: character.}{.} +\item{\code{play_text}: character.}{.} +\item{\code{down}: double.}{.} +\item{\code{distance}: double.}{.} +\item{\code{yards_to_goal}: double.}{.} +\item{\code{yards_gained}: double.}{.} +\item{\code{penalty_1st_conv}: logical.}{.} +\item{\code{new_series}: double.}{.} +\item{\code{change_of_pos_team}: double.}{.} +\item{\code{lag_change_of_pos_team}: double.}{.} +\item{\code{orig_play_type}: character.}{.} +\item{\code{lead_play_type}: character.}{.} +\item{\code{lag_play_type}: character.}{.} +\item{\code{lag_play_type2}: character.}{.} +\item{\code{lag_play_type3}: character.}{.} +\item{\code{row}: integer.}{.} +\item{\code{drive_play_number}: double.}{.} +\item{\code{drive_event_number}: double.}{.} +\item{\code{lag_play_text}: character.}{.} +\item{\code{lag_play_text2}: character.}{.} +\item{\code{lead_play_text}: character.}{.} +\item{\code{firstD_by_kickoff}: double.}{.} +\item{\code{firstD_by_poss}: double.}{.} +\item{\code{firstD_by_penalty}: double.}{.} +\item{\code{firstD_by_yards}: double.}{.} +\item{\code{lag_first_by_penalty}: double.}{.} +\item{\code{lag_first_by_penalty2}: double.}{.} +\item{\code{lag_first_by_yards}: double.}{.} +\item{\code{lag_first_by_yards2}: double.}{.} +\item{\code{first_by_penalty}: double.}{.} +\item{\code{first_by_yards}: double.}{.} +\item{\code{play_after_turnover}: double.}{.} +\item{\code{lag_change_of_poss}: double.}{.} +\item{\code{lag_kickoff_play}: double.}{.} +\item{\code{lag_punt}: double.}{.} +\item{\code{lag_scoring_play}: double.}{.} +\item{\code{lag_turnover_vec}: double.}{.} +\item{\code{lag_downs_turnover}: double.}{.} +\item{\code{lag_defense_score_play}: double.}{.} +\item{\code{EPA}: double.}{.} +\item{\code{ep_before}: double.}{.} +\item{\code{ep_after}: double.}{.} +\item{\code{wpa}: double.}{.} +\item{\code{wp_before}: double.}{.} +\item{\code{wp_after}: double.}{.} +\item{\code{def_wp_before}: double.}{.} +\item{\code{def_wp_after}: double.}{.} +\item{\code{penalty_detail}: character.}{.} +\item{\code{yds_penalty}: double.}{.} +\item{\code{downs_turnover}: double.}{.} +\item{\code{turnover}: double.}{.} +\item{\code{pos_score_diff_start}: double.}{.} +\item{\code{pos_score_pts}: double.}{.} +\item{\code{pos_team_score}: integer.}{.} +\item{\code{def_pos_team_score}: integer.}{.} +\item{\code{log_ydstogo}: double.}{.} +\item{\code{ExpScoreDiff}: double.}{.} +\item{\code{ExpScoreDiff_Time_Ratio}: double.}{.} +\item{\code{half_clock.minutes}: double.}{.} +\item{\code{TimeSecsRem}: double.}{.} +\item{\code{adj_TimeSecsRem}: double.}{.} +\item{\code{Goal_To_Go}: logical.}{.} +\item{\code{Under_two}: logical.}{.} +\item{\code{home}: character.}{.} +\item{\code{away}: character.}{.} +\item{\code{home_wp_before}: double.}{.} +\item{\code{away_wp_before}: double.}{.} +\item{\code{home_wp_after}: double.}{.} +\item{\code{away_wp_after}: double.}{.} +\item{\code{end_of_half}: double.}{.} +\item{\code{pos_team_receives_2H_kickoff}: double.}{.} +\item{\code{lead_pos_team}: character.}{.} +\item{\code{lag_pos_team}: character.}{.} +\item{\code{Under_three}: logical.}{.} +\item{\code{down_end}: integer.}{.} +\item{\code{distance_end}: double.}{.} +\item{\code{log_ydstogo_end}: double.}{.} +\item{\code{yards_to_goal_end}: double.}{.} +\item{\code{TimeSecsRem_end}: double.}{.} +\item{\code{Goal_To_Go_end}: logical.}{.} +\item{\code{Under_two_end}: logical.}{.} +\item{\code{def_EPA}: double.}{.} +\item{\code{offense_score_play}: double.}{.} +\item{\code{defense_score_play}: double.}{.} +\item{\code{ppa}: character.}{.} +\item{\code{yard_line}: integer.}{.} +\item{\code{scoring}: logical.}{.} +\item{\code{pos_team_timeouts_rem_before}: double.}{.} +\item{\code{def_pos_team_timeouts_rem_before}: double.}{.} +\item{\code{pos_team_timeouts}: integer.}{.} +\item{\code{def_pos_team_timeouts}: integer.}{.} +\item{\code{pos_score_diff}: integer.}{.} +\item{\code{pos_score_diff_start_end}: double.}{.} +\item{\code{offense_play}: character.}{.} +\item{\code{defense_play}: character.}{.} +\item{\code{offense_receives_2H_kickoff}: double.}{.} +\item{\code{change_of_poss}: double.}{.} +\item{\code{score_pts}: double.}{.} +\item{\code{score_diff_start}: double.}{.} +\item{\code{score_diff}: integer.}{.} +\item{\code{offense_score}: integer.}{.} +\item{\code{defense_score}: integer.}{.} +\item{\code{offense_conference}: character.}{.} +\item{\code{defense_conference}: character.}{.} +\item{\code{off_timeout_called}: double.}{.} +\item{\code{def_timeout_called}: double.}{.} +\item{\code{offense_timeouts}: integer.}{.} +\item{\code{defense_timeouts}: integer.}{.} +\item{\code{off_timeouts_rem_before}: double.}{.} +\item{\code{def_timeouts_rem_before}: double.}{.} +\item{\code{rusher_player_name}: character.}{.} +\item{\code{yds_rushed}: double.}{.} +\item{\code{passer_player_name}: character.}{.} +\item{\code{receiver_player_name}: character.}{.} +\item{\code{yds_receiving}: double.}{.} +\item{\code{yds_sacked}: double.}{.} +\item{\code{sack_players}: character.}{.} +\item{\code{sack_player_name}: character.}{.} +\item{\code{sack_player_name2}: character.}{.} +\item{\code{pass_breakup_player_name}: character.}{.} +\item{\code{interception_player_name}: character.}{.} +\item{\code{yds_int_return}: double.}{.} +\item{\code{fumble_player_name}: character.}{.} +\item{\code{fumble_forced_player_name}: character.}{.} +\item{\code{fumble_recovered_player_name}: character.}{.} +\item{\code{yds_fumble_return}: double.}{.} +\item{\code{punter_player_name}: character.}{.} +\item{\code{yds_punted}: double.}{.} +\item{\code{punt_returner_player_name}: character.}{.} +\item{\code{yds_punt_return}: double.}{.} +\item{\code{yds_punt_gained}: double.}{.} +\item{\code{punt_block_player_name}: character.}{.} +\item{\code{punt_block_return_player_name}: character.}{.} +\item{\code{fg_kicker_player_name}: character.}{.} +\item{\code{yds_fg}: double.}{.} +\item{\code{fg_block_player_name}: character.}{.} +\item{\code{fg_return_player_name}: character.}{.} +\item{\code{kickoff_player_name}: character.}{.} +\item{\code{yds_kickoff}: double.}{.} +\item{\code{kickoff_returner_player_name}: character.}{.} +\item{\code{yds_kickoff_return}: double.}{.} +\item{\code{new_id}: double.}{.} +\item{\code{orig_drive_number}: integer.}{.} +\item{\code{drive_number}: integer.}{.} +\item{\code{drive_result_detailed}: character.}{.} +\item{\code{new_drive_pts}: double.}{.} +\item{\code{drive_id}: double.}{.} +\item{\code{drive_result}: character.}{.} +\item{\code{drive_start_yards_to_goal}: double.}{.} +\item{\code{drive_end_yards_to_goal}: integer.}{.} +\item{\code{drive_yards}: integer.}{.} +\item{\code{drive_scoring}: double.}{.} +\item{\code{drive_pts}: double.}{.} +\item{\code{drive_start_period}: integer.}{.} +\item{\code{drive_end_period}: integer.}{.} +\item{\code{drive_time_minutes_start}: integer.}{.} +\item{\code{drive_time_seconds_start}: integer.}{.} +\item{\code{drive_time_minutes_end}: integer.}{.} +\item{\code{drive_time_seconds_end}: integer.}{.} +\item{\code{drive_time_minutes_elapsed}: integer.}{.} +\item{\code{drive_time_seconds_elapsed}: integer.}{.} +\item{\code{drive_numbers}: double.}{.} +\item{\code{number_of_drives}: double.}{.} +\item{\code{pts_scored}: double.}{.} +\item{\code{drive_result_detailed_flag}: character.}{.} +\item{\code{drive_result2}: character.}{.} +\item{\code{drive_num}: double.}{.} +\item{\code{lag_drive_result_detailed}: character.}{.} +\item{\code{lead_drive_result_detailed}: character.}{.} +\item{\code{lag_new_drive_pts}: double.}{.} +\item{\code{id_drive}: character.}{.} +\item{\code{rush}: double.}{.} +\item{\code{rush_td}: double.}{.} +\item{\code{pass}: double.}{.} +\item{\code{pass_td}: double.}{.} +\item{\code{completion}: double.}{.} +\item{\code{pass_attempt}: double.}{.} +\item{\code{target}: double.}{.} +\item{\code{sack_vec}: double.}{.} +\item{\code{sack}: double.}{.} +\item{\code{int}: double.}{.} +\item{\code{int_td}: double.}{.} +\item{\code{turnover_vec}: double.}{.} +\item{\code{turnover_vec_lag}: double.}{.} +\item{\code{turnover_indicator}: double.}{.} +\item{\code{kickoff_play}: double.}{.} +\item{\code{receives_2H_kickoff}: double.}{.} +\item{\code{missing_yard_flag}: logical.}{.} +\item{\code{scoring_play}: double.}{.} +\item{\code{td_play}: double.}{.} +\item{\code{touchdown}: double.}{.} +\item{\code{safety}: double.}{.} +\item{\code{fumble_vec}: double.}{.} +\item{\code{kickoff_tb}: double.}{.} +\item{\code{kickoff_onside}: double.}{.} +\item{\code{kickoff_oob}: double.}{.} +\item{\code{kickoff_fair_catch}: double.}{.} +\item{\code{kickoff_downed}: double.}{.} +\item{\code{kickoff_safety}: double.}{.} +\item{\code{kick_play}: double.}{.} +\item{\code{punt}: double.}{.} +\item{\code{punt_play}: double.}{.} +\item{\code{punt_tb}: double.}{.} +\item{\code{punt_oob}: double.}{.} +\item{\code{punt_fair_catch}: double.}{.} +\item{\code{punt_downed}: double.}{.} +\item{\code{punt_safety}: double.}{.} +\item{\code{punt_blocked}: double.}{.} +\item{\code{penalty_safety}: double.}{.} +\item{\code{fg_inds}: double.}{.} +\item{\code{fg_made}: logical.}{.} +\item{\code{fg_make_prob}: double.}{.} +\item{\code{home_EPA}: double.}{.} +\item{\code{away_EPA}: double.}{.} +\item{\code{home_EPA_rush}: double.}{.} +\item{\code{away_EPA_rush}: double.}{.} +\item{\code{home_EPA_pass}: double.}{.} +\item{\code{away_EPA_pass}: double.}{.} +\item{\code{total_home_EPA}: double.}{.} +\item{\code{total_away_EPA}: double.}{.} +\item{\code{total_home_EPA_rush}: double.}{.} +\item{\code{total_away_EPA_rush}: double.}{.} +\item{\code{total_home_EPA_pass}: double.}{.} +\item{\code{total_away_EPA_pass}: double.}{.} +\item{\code{net_home_EPA}: double.}{.} +\item{\code{net_away_EPA}: double.}{.} +\item{\code{net_home_EPA_rush}: double.}{.} +\item{\code{net_away_EPA_rush}: double.}{.} +\item{\code{net_home_EPA_pass}: double.}{.} +\item{\code{net_away_EPA_pass}: double.}{.} +\item{\code{success}: double.}{.} +\item{\code{epa_success}: double.}{.} +\item{\code{rz_play}: double.}{.} +\item{\code{scoring_opp}: double.}{.} +\item{\code{middle_8}: logical.}{.} +\item{\code{stuffed_run}: double.}{.} +\item{\code{spread}: double.}{.} +\item{\code{formatted_spread}: character.}{.} +\item{\code{No_Score_before}: double.}{.} +\item{\code{FG_before}: double.}{.} +\item{\code{Opp_FG_before}: double.}{.} +\item{\code{Opp_Safety_before}: double.}{.} +\item{\code{Opp_TD_before}: double.}{.} +\item{\code{Safety_before}: double.}{.} +\item{\code{TD_before}: double.}{.} +\item{\code{No_Score_after}: double.}{.} +\item{\code{FG_after}: double.}{.} +\item{\code{Opp_FG_after}: double.}{.} +\item{\code{Opp_Safety_after}: double.}{.} +\item{\code{Opp_TD_after}: double.}{.} +\item{\code{Safety_after}: double.}{.} +\item{\code{TD_after}: double.}{.} +\item{\code{penalty_flag}: logical.}{.} +\item{\code{penalty_declined}: logical.}{.} +\item{\code{penalty_no_play}: logical.}{.} +\item{\code{penalty_offset}: logical.}{.} +\item{\code{penalty_text}: logical.}{.} +\item{\code{penalty_play_text}: character.}{.} +\item{\code{lead_wp_before2}: double.}{.} +\item{\code{wpa_half_end}: double.}{.} +\item{\code{wpa_base}: double.}{.} +\item{\code{wpa_base_nxt}: double.}{.} +\item{\code{wpa_change}: double.}{.} +\item{\code{wpa_change_nxt}: double.}{.} +\item{\code{wpa_base_ind}: double.}{.} +\item{\code{wpa_base_nxt_ind}: double.}{.} +\item{\code{wpa_change_ind}: double.}{.} +\item{\code{wpa_change_nxt_ind}: double.}{.} +\item{\code{lead_wp_before}: double.}{.} +\item{\code{lead_pos_team2}: character.}{.} +\item{\code{lag_change_of_pos_team2}: double.}{.} +\item{\code{lag_punt2}: double.}{.} +\item{\code{lag_score_diff}: double.}{.} +\item{\code{lag_offense_play}: character.}{.} +\item{\code{lead_offense_play}: character.}{.} +\item{\code{lead_offense_play2}: character.}{.} +\item{\code{lag_pos_score_diff}: double.}{.} +\item{\code{lag_off_timeouts}: double.}{.} +\item{\code{lag_def_timeouts}: double.}{.} +\item{\code{lag_TimeSecsRem2}: double.}{.} +\item{\code{lag_TimeSecsRem}: double.}{.} +\item{\code{lead_TimeSecsRem}: double.}{.} +\item{\code{lead_TimeSecsRem2}: double.}{.} +\item{\code{lag_yards_to_goal2}: integer.}{.} +\item{\code{lag_yards_to_goal}: integer.}{.} +\item{\code{lead_yards_to_goal}: double.}{.} +\item{\code{lead_yards_to_goal2}: integer.}{.} +\item{\code{lag_down2}: double.}{.} +\item{\code{lag_down}: double.}{.} +\item{\code{lead_down}: double.}{.} +\item{\code{lead_down2}: double.}{.} +\item{\code{lead_distance}: double.}{.} +\item{\code{lead_distance2}: integer.}{.} +\item{\code{lead_play_type2}: character.}{.} +\item{\code{lead_play_type3}: character.}{.} +\item{\code{lag_ep_before3}: double.}{.} +\item{\code{lag_ep_before2}: double.}{.} +\item{\code{lag_ep_before}: double.}{.} +\item{\code{lead_ep_before}: double.}{.} +\item{\code{lead_ep_before2}: double.}{.} +\item{\code{lag_ep_after}: double.}{.} +\item{\code{lag_ep_after2}: double.}{.} +\item{\code{lag_ep_after3}: double.}{.} +\item{\code{lead_ep_after}: double.}{.} +\item{\code{lead_ep_after2}: double.}{.} +\item{\code{play_number}: integer.}{.} +\item{\code{over_under}: double.}{.} +\item{\code{event}: double.}{.} +\item{\code{game_event_number}: double.}{.} +\item{\code{game_row_number}: integer.}{.} +\item{\code{half_event}: double.}{.} +\item{\code{half_event_number}: double.}{.} +\item{\code{half_row_number}: integer.}{.} +\item{\code{lag_distance3}: integer.}{.} +\item{\code{lag_distance2}: integer.}{.} +\item{\code{lag_distance}: integer.}{.} +\item{\code{lag_yards_gained3}: integer.}{.} +\item{\code{lag_yards_gained2}: integer.}{.} +\item{\code{lag_yards_gained}: integer.}{.} +\item{\code{lead_yards_gained}: integer.}{.} +\item{\code{lead_yards_gained2}: integer.}{.} +\item{\code{lag_play_text3}: character.}{.} +\item{\code{lead_play_text2}: character.}{.} +\item{\code{lead_play_text3}: character.}{.} +\item{\code{lag_change_of_poss2}: double.}{.} +\item{\code{lag_change_of_poss3}: double.}{.} +\item{\code{lag_change_of_pos_team3}: double.}{.} +\item{\code{lag_kickoff_play2}: double.}{.} +\item{\code{lag_kickoff_play3}: double.}{.} +\item{\code{lag_punt3}: double.}{.} +\item{\code{lag_scoring_play2}: double.}{.} +\item{\code{lag_scoring_play3}: double.}{.} +\item{\code{lag_turnover_vec2}: double.}{.} +\item{\code{lag_turnover_vec3}: double.}{.} +\item{\code{lag_downs_turnover2}: double.}{.} +\item{\code{lag_downs_turnover3}: double.}{.} +\item{\code{drive_event}: double.}{.} +\item{\code{lag_first_by_penalty3}: double.}{.} +\item{\code{lag_first_by_yards3}: double.}{.} } } \description{ -CFBD Play by Play Data - Extract CFB (D-I) Play by Play Data - For plays } \keyword{Play-by-Play} diff --git a/man/cfbd_play.Rd b/man/cfbd_play.Rd index 3c33e6b1..8cd13519 100644 --- a/man/cfbd_play.Rd +++ b/man/cfbd_play.Rd @@ -22,8 +22,8 @@ cfbd_plays( year = 2020, season_type = "regular", - week = 4, - team = "Florida State", + week = 1, + team = NULL, offense = NULL, defense = NULL, conference = NULL, @@ -70,103 +70,130 @@ PAC, MAC, MWC, CUSA, Ind, SBC, AAC, Western, MVIAA, SWC, PCC, Big 6, etc.)} \item{defense_conference}{Select conference name (example: ACC, B1G, B12, SEC,\cr PAC, MAC, MWC, CUSA, Ind, SBC, AAC, Western, MVIAA, SWC, PCC, Big 6, etc.)} -\item{play_type}{Select play type (example: see the \code{\link[cfbfastR:cfbd_play_type_df]{cfbd_play_type_df}})} +\item{play_type}{Select play type (example: see the \link{cfbd_play_type_df})} \item{verbose}{Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function} -\item{game_id}{(\emph{Integer} optional): Game ID filter for querying a single game\cr -Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function} +\item{game_id}{(\emph{Integer} optional): Game ID filter for querying a single game +Can be found using the \code{\link[=cfbd_game_info]{cfbd_game_info()}} function} -\item{athlete_id}{(\emph{Integer} optional): Athlete ID filter for querying a single athlete\cr -Can be found using the \code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_player_info()}} function.} +\item{athlete_id}{(\emph{Integer} optional): Athlete ID filter for querying a single athlete +Can be found using the \code{\link[=cfbd_player_info]{cfbd_player_info()}} function.} -\item{stat_type_id}{(\emph{Integer} optional): Stat Type ID filter for querying a single stat type\cr -Can be found using the \code{\link[cfbfastR:cfbd_play_stats_types]{cfbfastR::cfbd_play_stats_types()}} function} +\item{stat_type_id}{(\emph{Integer} optional): Stat Type ID filter for querying a single stat type +Can be found using the \code{\link[=cfbd_play_stats_types]{cfbd_play_stats_types()}} function} } \value{ -\code{\link[cfbfastR:cfbd_plays]{cfbfastR::cfbd_plays()}} +\code{\link[=cfbd_plays]{cfbd_plays()}} - A data frame with 29 columns: +\describe{ +\item{\code{play_id}: character.}{Referencing play id.} +\item{\code{offense}: character.}{Offense on the field.} +\item{\code{offense_conference}: character.}{Conference of the offense on the field.} +\item{\code{defense}: character.}{Defense on the field.} +\item{\code{defense_conference}: character.}{Conference of the defense on the field.} +\item{\code{home}: character.}{Home team.} +\item{\code{away}: character.}{Away team.} +\item{\code{offense_score}: integer.}{Offense's post-play score.} +\item{\code{defense_score}: integer.}{Defense's post-play score.} +\item{\code{game_id}: integer.}{Referencing game id.} +\item{\code{drive_id}: character.}{Referencing drive id.} +\item{\code{drive_number}: integer.}{Drive number in the game.} +\item{\code{play_number}: integer.}{Play number in the game.} +\item{\code{period}: integer.}{Game period (quarter).} +\item{\code{offense_timeouts}: integer.}{Timeouts for the offense at the end of the play.} +\item{\code{defense_timeouts}: integer.}{Timeouts for the defense at the end of the play.} +\item{\code{yard_line}: integer.}{Yard line (~0-50) of the play.} +\item{\code{yards_to_goal}: integer.}{Yards to the goal line (~0-100).} +\item{\code{down}: integer.}{Down of the play.} +\item{\code{distance}: integer.}{Distance to the sticks, i.e. 1st down or goal-line in goal-to-go situations.} +\item{\code{scoring}: logical.}{Scoring play flag.} +\item{\code{yards_gained}: integer.}{Yards net gained by the offense on the play.} +\item{\code{play_type}: character.}{Categorical label of the type of the play.} +\item{\code{play_text}: character.}{A text description of the play.} +\item{\code{ppa}: character.}{Predicted Points Added (calculated by CFBD).} +\item{\code{clock.minutes}: integer.}{Minutes left on the clock.} +\item{\code{clock.seconds}: integer.}{Seconds left on the clock.} +} -\code{\link[cfbfastR:cfbd_play_stats_player]{cfbfastR::cfbd_play_stats_player()}} - A data frame with 54 variables: +\code{\link[=cfbd_play_stats_player]{cfbd_play_stats_player()}} - A data frame with 54 variables: \describe{ -\item{\code{play_id}}{character.} -\item{\code{game_id}}{integer.} -\item{\code{season}}{integer.} -\item{\code{week}}{integer.} -\item{\code{opponent}}{character.} -\item{\code{team_score}}{integer.} -\item{\code{opponent_score}}{integer.} -\item{\code{drive_id}}{character.} -\item{\code{period}}{integer.} -\item{\code{yards_to_goal}}{integer.} -\item{\code{down}}{integer.} -\item{\code{distance}}{integer.} -\item{\code{reception_player_id}}{character.} -\item{\code{reception_player}}{character.} -\item{\code{reception_yds}}{integer.} -\item{\code{completion_player_id}}{character.} -\item{\code{completion_player}}{character.} -\item{\code{completion_yds}}{integer.} -\item{\code{rush_player_id}}{character.} -\item{\code{rush_player}}{character.} -\item{\code{rush_yds}}{integer.} -\item{\code{interception_player_id}}{character.} -\item{\code{interception_player}}{character.} -\item{\code{interception_stat}}{integer.} -\item{\code{interception_thrown_player_id}}{character.} -\item{\code{interception_thrown_player}}{character.} -\item{\code{interception_thrown_stat}}{integer.} -\item{\code{touchdown_player_id}}{character.} -\item{\code{touchdown_player}}{character.} -\item{\code{touchdown_stat}}{integer.} -\item{\code{incompletion_player_id}}{character.} -\item{\code{incompletion_player}}{character.} -\item{\code{incompletion_stat}}{integer.} -\item{\code{target_player_id}}{character.} -\item{\code{target_player}}{character.} -\item{\code{target_stat}}{integer.} -\item{\code{fumble_recovered_player_id}}{logical.} -\item{\code{fumble_recovered_player}}{logical.} -\item{\code{fumble_recovered_stat}}{logical.} -\item{\code{fumble_forced_player_id}}{logical.} -\item{\code{fumble_forced_player}}{logical.} -\item{\code{fumble_forced_stat}}{logical.} -\item{\code{fumble_player_id}}{logical.} -\item{\code{fumble_player}}{logical.} -\item{\code{fumble_stat}}{logical.} -\item{\code{sack_player_id}}{character.} -\item{\code{sack_player}}{character.} -\item{\code{sack_stat}}{integer.} -\item{\code{sack_taken_player_id}}{character.} -\item{\code{sack_taken_player}}{character.} -\item{\code{sack_taken_stat}}{integer.} -\item{\code{pass_breakup_player_id}}{logical.} -\item{\code{pass_breakup_player}}{logical.} -\item{\code{pass_breakup_stat}}{logical.} +\item{\code{play_id}: character.}{Referencing play id.} +\item{\code{game_id}: integer.}{Referencing game id.} +\item{\code{season}: integer.}{Season of the play.} +\item{\code{week}: integer.}{Week of the play.} +\item{\code{opponent}: character.}{Opponent of the offense on the play.} +\item{\code{team_score}: integer.}{Offense team score.} +\item{\code{opponent_score}: integer.}{Defense team score.} +\item{\code{drive_id}: character.}{Referencing drive id.} +\item{\code{period}: integer.}{Game period (quarter) of the play.} +\item{\code{yards_to_goal}: integer.}{Yards to the goal line (~0-100).} +\item{\code{down}: integer.}{Down of the play.} +\item{\code{distance}: integer.}{Distance to the sticks, i.e. 1st down or goal-line in goal-to-go situations.} +\item{\code{reception_player_id}: character.}{Pass receiver player reference id.} +\item{\code{reception_player}: character.}{Pass receiver player name.} +\item{\code{reception_yds}: integer.}{Reception yards.} +\item{\code{completion_player_id}: character.}{Passing player reference id.} +\item{\code{completion_player}: character.}{Passing player name.} +\item{\code{completion_yds}: integer.}{Passing yards.} +\item{\code{rush_player_id}: character.}{Rushing player reference id.} +\item{\code{rush_player}: character.}{Rushing player name.} +\item{\code{rush_yds}: integer.}{Rushing yards.} +\item{\code{interception_player_id}: character.}{Intercepting player reference id.} +\item{\code{interception_player}: character.}{Intercepting player name.} +\item{\code{interception_stat}: integer.}{Intercepting stat.} +\item{\code{interception_thrown_player_id}: character.}{Interception passing player reference id.} +\item{\code{interception_thrown_player}: character.}{Interception passing player name.} +\item{\code{interception_thrown_stat}: integer.}{Interception thrown stat.} +\item{\code{touchdown_player_id}: character.}{Touchdown scoring player reference id.} +\item{\code{touchdown_player}: character.}{Touchdown scoring player name.} +\item{\code{touchdown_stat}: integer.}{Touchdown scoring stat.} +\item{\code{incompletion_player_id}: character.}{Incomplete receiver player reference id.} +\item{\code{incompletion_player}: character.}{Incomplete receiver player name.} +\item{\code{incompletion_stat}: integer.}{Incomplete stat.} +\item{\code{target_player_id}: character.}{Targeted receiver player reference id.} +\item{\code{target_player}: character.}{Targeted receiver player name.} +\item{\code{target_stat}: integer.}{Target stat.} +\item{\code{fumble_recovered_player_id}: logical.}{Fumble recovering player reference id.} +\item{\code{fumble_recovered_player}: logical.}{Fumble recovering player name.} +\item{\code{fumble_recovered_stat}: logical.}{Fumble recovered stat.} +\item{\code{fumble_forced_player_id}: logical.}{Fumble forcing player reference id.} +\item{\code{fumble_forced_player}: logical.}{Fumble forcing player name.} +\item{\code{fumble_forced_stat}: logical.}{Fumble forced stat.} +\item{\code{fumble_player_id}: logical.}{Fumbling player reference id.} +\item{\code{fumble_player}: logical.}{Fumbling player name.} +\item{\code{fumble_stat}: logical.}{Fumble stat.} +\item{\code{sack_player_id}: character.}{Sacking player(s) reference id.} +\item{\code{sack_player}: character.}{Sacking player(s) name.} +\item{\code{sack_stat}: integer.}{Sack stat.} +\item{\code{sack_taken_player_id}: character.}{Sack taking player reference id.} +\item{\code{sack_taken_player}: character.}{Sack taking player name.} +\item{\code{sack_taken_stat}: integer.}{Sack taken stat.} +\item{\code{pass_breakup_player_id}: logical.}{Pass breakup player reference id.} +\item{\code{pass_breakup_player}: logical.}{Pass breakup player name.} +\item{\code{pass_breakup_stat}: logical.}{Pass breakup (PBU) stat.} } -\code{\link[cfbfastR:cfbd_play_stats_types]{cfbfastR::cfbd_play_stats_types()}} - A data frame with 22 rows and 2 variables: +\code{\link[=cfbd_play_stats_types]{cfbd_play_stats_types()}} - A data frame with 22 rows and 2 variables: \describe{ -\item{play_stat_type_id}{Referencing play stat type ID} -\item{name}{Type of play stats} +\item{\code{play_stat_type_id}: integer}{Referencing play stat type ID.} +\item{\code{name}: character}{Type of play stats.} } -\code{\link[cfbfastR:cfbd_play_types]{cfbfastR::cfbd_play_types()}} - A data frame with 48 rows and 3 variables: +\code{\link[=cfbd_play_types]{cfbd_play_types()}} - A data frame with 48 rows and 3 variables: \describe{ -\item{play_type_id}{Referencing play type id} -\item{text}{play type description} -\item{abbreviation}{play type abbreviation used for function call} +\item{\code{play_type_id}: integer}{Referencing play type id.} +\item{\code{text}: character}{play type description.} +\item{\code{abbreviation}: character}{play type abbreviation used for function call} } } \description{ -CFBD Plays Endpoint - -College Football Plays - -Gets player info associated by play - -College Football Mapping for Play Stats Types - -College Football Mapping for Play Types +College football plays data +\describe{ +\item{\code{cfbd_plays()}:}{CFBD's College Football Play-by-Play} +\item{\code{cfbd_play_stats_player()}:}{Gets player info associated by play.} +\item{\code{cfbd_play_stats_types()}:}{Gets CFBD play stat types.} +\item{\code{cfbd_play_types()}:}{Gets CFBD play types} +} } \examples{ \donttest{ @@ -175,7 +202,6 @@ College Football Mapping for Play Types \donttest{ cfbd_play_stats_types() } - } \keyword{PBP} \keyword{Player} diff --git a/man/cfbd_players.Rd b/man/cfbd_players.Rd index 7126039d..014e9afb 100644 --- a/man/cfbd_players.Rd +++ b/man/cfbd_players.Rd @@ -3,6 +3,7 @@ \name{cfbd_players} \alias{cfbd_players} \alias{cfbd_player_info} +\alias{cfbd_player} \alias{cfbd_player_returning} \alias{cfbd_player_usage} \title{CFBD Players Endpoint} @@ -56,77 +57,80 @@ Position Group - options include:\cr \item{verbose}{Logical parameter (TRUE/FALSE, default: FALSE) to return warnings and messages from function} -\item{conference}{(\emph{String} optional): Conference abbreviation - Select a valid FBS conference\cr +\item{conference}{(\emph{String} optional): Conference abbreviation - Select a valid FBS conferencer\cr Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC} \item{athlete_id}{(\emph{Integer} optional): Athlete ID filter for querying a single athlete\cr -Can be found using the \code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_player_info()}} function.} +Can be found using the \code{\link[=cfbd_player_info]{cfbd_player_info()}} function.} \item{excl_garbage_time}{(\emph{Logical} default FALSE): Select whether to exclude Garbage Time (TRUE/FALSE)} } \value{ -\code{\link[cfbfastR:cfbd_player_info]{cfbfastR::cfbd_player_info()}} - A data frame with 12 variables: +\code{\link[=cfbd_player_info]{cfbd_player_info()}} - A data frame with 12 variables: \describe{ -\item{\code{athlete_id}}{character. Unique player identifier \code{athlete_id}.} -\item{\code{team}}{character. Team of the player.} -\item{\code{name}}{character. Player name.} -\item{\code{first_name}}{character. Player first name.} -\item{\code{last_name}}{character. Player last name.} -\item{\code{weight}}{integer. Player weight.} -\item{\code{height}}{integer. Player height.} -\item{\code{jersey}}{integer. Player jersey number.} -\item{\code{position}}{character. Player position.} -\item{\code{home_town}}{character. Player home town.} -\item{\code{team_color}}{character. Player team color.} -\item{\code{team_color_secondary}}{character. Player team secondary color.} +\item{\code{athlete_id}:character.}{Unique player identifier \code{athlete_id}.} +\item{\code{team}:character.}{Team of the player.} +\item{\code{name}:character.}{Player name.} +\item{\code{first_name}:character.}{Player first name.} +\item{\code{last_name}:character.}{Player last name.} +\item{\code{weight}:integer.}{Player weight.} +\item{\code{height}:integer.}{Player height.} +\item{\code{jersey}:integer.}{Player jersey number.} +\item{\code{position}:character.}{Player position.} +\item{\code{home_town}:character.}{Player home town.} +\item{\code{team_color}:character.}{Player team color.} +\item{\code{team_color_secondary}:character.}{Player team secondary color.} } -\code{\link[cfbfastR:cfbd_player_returning]{cfbfastR::cfbd_player_returning()}} - A data frame with 15 variables: +\code{\link[=cfbd_player_returning]{cfbd_player_returning()}} - A data frame with 15 variables: \describe{ -\item{\code{season}}{integer.} -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{total_ppa}}{double.} -\item{\code{total_passing_ppa}}{double.} -\item{\code{total_receiving_ppa}}{double.} -\item{\code{total_rushing_ppa}}{double.} -\item{\code{percent_ppa}}{double.} -\item{\code{percent_passing_ppa}}{double.} -\item{\code{percent_receiving_ppa}}{double.} -\item{\code{percent_rushing_ppa}}{double.} -\item{\code{usage}}{double.} -\item{\code{passing_usage}}{double.} -\item{\code{receiving_usage}}{double.} -\item{\code{rushing_usage}}{double.} +\item{\code{season}:integer.}{Returning player season.} +\item{\code{team}:character.}{Team name.} +\item{\code{conference}:character.}{Conference of team.} +\item{\code{total_ppa}:double.}{Total predicted points added returning.} +\item{\code{total_passing_ppa}:double.}{Total passing predicted points added returning.} +\item{\code{total_receiving_ppa}:double.}{Total receiving predicted points added returning.} +\item{\code{total_rushing_ppa}:double.}{Total rushing predicted points added returning.} +\item{\code{percent_ppa}:double.}{Percentage of prior year's predicted points added returning.} +\item{\code{percent_passing_ppa}:double.}{Percentage of prior year's passing predicted points added returning.} +\item{\code{percent_receiving_ppa}:double.}{Percentage of prior year's receiving predicted points added returning.} +\item{\code{percent_rushing_ppa}:double.}{Percentage of prior year's rushing predicted points added returning.} +\item{\code{usage}:double.}{.} +\item{\code{passing_usage}:double.}{.} +\item{\code{receiving_usage}:double.}{.} +\item{\code{rushing_usage}:double.}{.} } -\code{\link[cfbfastR:cfbd_player_usage]{cfbfastR::cfbd_player_usage()}} - A data frame with 14 variables: +\code{\link[=cfbd_player_usage]{cfbd_player_usage()}} - A data frame with 14 variables: \describe{ -\item{\code{season}}{integer.} -\item{\code{athlete_id}}{character.} -\item{\code{name}}{character.} -\item{\code{position}}{character.} -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{usg_overall}}{double.} -\item{\code{usg_pass}}{double.} -\item{\code{usg_rush}}{double.} -\item{\code{usg_1st_down}}{double.} -\item{\code{usg_2nd_down}}{double.} -\item{\code{usg_3rd_down}}{double.} -\item{\code{usg_standard_downs}}{double.} -\item{\code{usg_passing_downs}}{double.} +\item{\code{season}: integer.}{Player usage season.} +\item{\code{athlete_id}: character.}{Referencing athlete id.} +\item{\code{name}: character.}{Athlete name.} +\item{\code{position}: character.}{Athlete position.} +\item{\code{team}: character.}{Team name.} +\item{\code{conference}: character.}{Conference of team.} +\item{\code{usg_overall}: double.}{Player usage of overall offense.} +\item{\code{usg_pass}: double.}{Player passing usage percentage.} +\item{\code{usg_rush}: double.}{Player rushing usage percentage.} +\item{\code{usg_1st_down}: double.}{Player first down usage percentage.} +\item{\code{usg_2nd_down}: double.}{Player second down usage percentage.} +\item{\code{usg_3rd_down}: double.}{Player third down usage percentage.} +\item{\code{usg_standard_downs}: double.}{Player standard down usage percentage.} +\item{\code{usg_passing_downs}: double.}{Player passing down usage percentage.} } } \description{ -CFBD Players Endpoint - -Player Information Search - -Player Returning Production +\describe{ +\item{\code{cfbd_player_info()}:}{Player Information Search.} +\item{\code{cfbd_player_returning()}:}{Player Returning Production} +\item{\code{cfbd_player_usage()}:}{Player Usage.} +} +} +\details{ +\code{\link[=cfbd_player_returning]{cfbd_player_returning()}} -Player Usage +\code{\link[=cfbd_player_usage]{cfbd_player_usage()}} } \examples{ \donttest{ diff --git a/man/cfbd_ratings.Rd b/man/cfbd_ratings.Rd index f0f10625..1a8fd455 100644 --- a/man/cfbd_ratings.Rd +++ b/man/cfbd_ratings.Rd @@ -41,93 +41,99 @@ Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC} } \value{ -\code{\link[cfbfastR:cfbd_rankings]{cfbfastR::cfbd_rankings()}} - A data frame with 9 variables: +\code{\link[=cfbd_rankings]{cfbd_rankings()}} - A data frame with 9 variables: \describe{ -\item{\code{season}}{integer.} -\item{\code{season_type}}{character.} -\item{\code{week}}{integer.} -\item{\code{poll}}{character.} -\item{\code{rank}}{integer.} -\item{\code{school}}{character.} -\item{\code{conference}}{character.} -\item{\code{first_place_votes}}{integer.} -\item{\code{points}}{integer.} +\item{\code{season}: integer.}{Rankings season.} +\item{\code{season_type}: character.}{Season type of rankings.} +\item{\code{week}: integer.}{Week of rankings.} +\item{\code{poll}: character.}{Name of the poll.} +\item{\code{rank}: integer.}{Rank in the poll.} +\item{\code{school}: character.}{Team name.} +\item{\code{conference}: character.}{Conference of the team.} +\item{\code{first_place_votes}: integer.}{Number of first place votes.} +\item{\code{points}: integer.}{Total poll points.} } -\code{\link[cfbfastR:cfbd_ratings_sp]{cfbfastR::cfbd_ratings_sp()}} - A data frame with 26 variables: +\code{\link[=cfbd_ratings_sp]{cfbd_ratings_sp()}} - A data frame with 26 variables: \describe{ -\item{\code{year}}{integer.} -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{rating}}{double.} -\item{\code{ranking}}{integer.} -\item{\code{second_order_wins}}{logical.} -\item{\code{sos}}{logical.} -\item{\code{offense_ranking}}{integer.} -\item{\code{offense_rating}}{double.} -\item{\code{offense_success}}{logical.} -\item{\code{offense_explosiveness}}{logical.} -\item{\code{offense_rushing}}{logical.} -\item{\code{offense_passing}}{logical.} -\item{\code{offense_standard_downs}}{logical.} -\item{\code{offense_passing_downs}}{logical.} -\item{\code{offense_run_rate}}{logical.} -\item{\code{offense_pace}}{logical.} -\item{\code{defense_ranking}}{integer.} -\item{\code{defense_rating}}{double.} -\item{\code{defense_success}}{logical.} -\item{\code{defense_explosiveness}}{logical.} -\item{\code{defense_rushing}}{logical.} -\item{\code{defense_passing}}{logical.} -\item{\code{defense_standard_downs}}{logical.} -\item{\code{defense_passing_downs}}{logical.} -\item{\code{defense_havoc_total}}{logical.} -\item{\code{defense_havoc_front_seven}}{logical.} -\item{\code{defense_havoc_db}}{logical.} -\item{\code{special_teams_rating}}{double.} +\item{\code{year}: integer.}{Season of the ratings.} +\item{\code{team}: character.}{Team name.} +\item{\code{conference}: character.}{Conference of the team.} +\item{\code{rating}: double.}{SP+ rating.} +\item{\code{ranking}: integer.}{Ranking in the SP+ ratings.} +\item{\code{second_order_wins}: logical.}{Total second-order wins - Not available for recent seasons.} +\item{\code{sos}: logical.}{Strength of schedule - Not available for recent seasons.} +\item{\code{offense_ranking}: integer.}{Overall offense ranking.} +\item{\code{offense_rating}: double.}{Overall offense rating.} +\item{\code{offense_success}: logical.}{Offense success rating - Not available for recent seasons.} +\item{\code{offense_explosiveness}: logical.}{Offense explosiveness rating - Not available for recent seasons.} +\item{\code{offense_rushing}: logical.}{Offense rushing rating - Not available for recent seasons.} +\item{\code{offense_passing}: logical.}{Offense passing rating - Not available for recent seasons.} +\item{\code{offense_standard_downs}: logical.}{Offense standard downs rating - Not available for recent seasons.} +\item{\code{offense_passing_downs}: logical.}{Offensive passing downs rating - Not available for recent seasons.} +\item{\code{offense_run_rate}: logical.}{Offense rushing rate - Not available for recent seasons.} +\item{\code{offense_pace}: logical.}{Offense pace factor - Not available for recent seasons.} +\item{\code{defense_ranking}: integer.}{Overall defense ranking.} +\item{\code{defense_rating}: double.}{Overall defense rating.} +\item{\code{defense_success}: logical.}{Defense success rating - Not available for recent seasons.} +\item{\code{defense_explosiveness}: logical.}{Defense explosiveness rating - Not available for recent seasons.} +\item{\code{defense_rushing}: logical.}{Defense rushing rating - Not available for recent seasons.} +\item{\code{defense_passing}: logical.}{Defense passing rating - Not available for recent seasons.} +\item{\code{defense_standard_downs}: logical.}{Defense standard downs rating - Not available for recent seasons.} +\item{\code{defense_passing_downs}: logical.}{Defensive passing downs rating - Not available for recent seasons.} +\item{\code{defense_havoc_total}: logical.}{Total defensive havoc rate - Not available for recent seasons.} +\item{\code{defense_havoc_front_seven}: logical.}{Defense havoc rate from front 7 players - Not available for recent seasons.} +\item{\code{defense_havoc_db}: logical.}{Defense havoc rate from defensive backs - Not available for recent seasons.} +\item{\code{special_teams_rating}: double.}{Special teams rating.} } -\code{\link[cfbfastR:cfbd_ratings_sp_conference]{cfbfastR::cfbd_ratings_sp_conference()}} - A data frame with 25 variables: +\code{\link[=cfbd_ratings_sp_conference]{cfbd_ratings_sp_conference()}} - A data frame with 25 variables: \describe{ -\item{\code{year}}{integer.} -\item{\code{conference}}{character.} -\item{\code{rating}}{double.} -\item{\code{second_order_wins}}{logical.} -\item{\code{sos}}{logical.} -\item{\code{offense_rating}}{double.} -\item{\code{offense_success}}{logical.} -\item{\code{offense_explosiveness}}{logical.} -\item{\code{offense_rushing}}{logical.} -\item{\code{offense_passing}}{logical.} -\item{\code{offense_standard_downs}}{logical.} -\item{\code{offense_passing_downs}}{logical.} -\item{\code{offense_run_rate}}{logical.} -\item{\code{offense_pace}}{logical.} -\item{\code{defense_rating}}{double.} -\item{\code{defense_success}}{logical.} -\item{\code{defense_explosiveness}}{logical.} -\item{\code{defense_rushing}}{logical.} -\item{\code{defense_passing}}{logical.} -\item{\code{defense_standard_downs}}{logical.} -\item{\code{defense_passing_downs}}{logical.} -\item{\code{defense_havoc_total}}{logical.} -\item{\code{defense_havoc_front_seven}}{logical.} -\item{\code{defense_havoc_db}}{logical.} -\item{\code{special_teams_rating}}{double.} +\item{\code{year}: integer.}{Season of the conference rating.} +\item{\code{conference}: character.}{Conference name.} +\item{\code{rating}: double.}{Conference SP+ rating.} +\item{\code{second_order_wins}: logical.}{Second-order wins for the conference - Not available for recent seasons.} +\item{\code{sos}: logical.}{Strength of schedule for the conference - Not available for recent seasons..} +\item{\code{offense_rating}: double.}{Overall offense rating for the conference.} +\item{\code{offense_success}: logical.}{Offense success rating for the conference - Not available for recent seasons.} +\item{\code{offense_explosiveness}: logical.}{Offense explosiveness rating for the conference - Not available for recent seasons.} +\item{\code{offense_rushing}: logical.}{Offense rushing rating for the conference - Not available for recent seasons.} +\item{\code{offense_passing}: logical.}{Offense passing rating for the conference - Not available for recent seasons.} +\item{\code{offense_standard_downs}: logical.}{Offense standard downs rating for the conference - Not available for recent seasons.} +\item{\code{offense_passing_downs}: logical.}{Offensive passing downs rating for the conference - Not available for recent seasons.} +\item{\code{offense_run_rate}: logical.}{Offense rushing rate for the conference - Not available for recent seasons.} +\item{\code{offense_pace}: logical.}{Offense pace factor for the conference - Not available for recent seasons.} +\item{\code{defense_ranking}: integer.}{Overall defense ranking for the conference.} +\item{\code{defense_rating}: double.}{Overall defense rating for the conference.} +\item{\code{defense_success}: logical.}{Defense success rating for the conference - Not available for recent seasons.} +\item{\code{defense_explosiveness}: logical.}{Defense explosiveness rating for the conference - Not available for recent seasons.} +\item{\code{defense_rushing}: logical.}{Defense rushing rating for the conference - Not available for recent seasons.} +\item{\code{defense_passing}: logical.}{Defense passing rating for the conference - Not available for recent seasons.} +\item{\code{defense_standard_downs}: logical.}{Defense standard downs rating for the conference - Not available for recent seasons.} +\item{\code{defense_passing_downs}: logical.}{Defensive passing downs rating for the conference - Not available for recent seasons.} +\item{\code{defense_havoc_total}: logical.}{Total defensive havoc rate for the conference - Not available for recent seasons.} +\item{\code{defense_havoc_front_seven}: logical.}{Defense havoc rate from front 7 players for the conference - Not available for recent seasons.} +\item{\code{defense_havoc_db}: logical.}{Defense havoc rate from defensive backs for the conference - Not available for recent seasons.} +\item{\code{special_teams_rating}: double.}{Special teams rating for the conference.} } -\code{\link[cfbfastR:cfbd_ratings_srs]{cfbfastR::cfbd_ratings_srs()}} - A data frame with 6 variables: +\code{\link[=cfbd_ratings_srs]{cfbd_ratings_srs()}} - A data frame with 6 variables: \describe{ -\item{\code{year}}{integer.} -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{division}}{logical.} -\item{\code{rating}}{double.} -\item{\code{ranking}}{integer.} +\item{\code{year}: integer.}{Season of the SRS rating.} +\item{\code{team}: character.}{Team name.} +\item{\code{conference}: character.}{Conference of the team.} +\item{\code{division}: logical.}{Division in the conference for the team.} +\item{\code{rating}: double.}{Simple Rating System (SRS) rating.} +\item{\code{ranking}: integer.}{Simple Rating System ranking within the group returned.} } } \description{ -Postseason polls are after Week 13 +\describe{ +\item{\code{cfbd_rankings()}: Gets Historical CFB poll rankings at a specific week}{.} +\item{\code{cfbd_ratings_sp()}: Get SP historical rating data}{.} +\item{\code{cfbd_ratings_sp_conference()}: Get SP conference-level historical rating data}{.} +\item{\code{cfbd_ratings_srs()}: Get SRS historical rating data}{.} +} At least one of \strong{year} or \strong{team} must be specified for the function to run @@ -143,7 +149,7 @@ cfbd_rankings(year = 2013, season_type = "postseason") } \donttest{ -cfbd_ratings_sp(year = 2019) +cfbd_ratings_sp(year = 2018) cfbd_ratings_sp(team = "Texas A&M") diff --git a/man/cfbd_recruiting.Rd b/man/cfbd_recruiting.Rd index abedd2c7..0405f981 100644 --- a/man/cfbd_recruiting.Rd +++ b/man/cfbd_recruiting.Rd @@ -3,9 +3,10 @@ \name{cfbd_recruiting} \alias{cfbd_recruiting} \alias{cfbd_recruiting_player} +\alias{recruiting} \alias{cfbd_recruiting_position} \alias{cfbd_recruiting_team} -\title{CFBD Recruiting Endpoint} +\title{CFB Recruiting Endpoint} \source{ \url{https://api.collegefootballdata.com/recruiting/players} @@ -61,75 +62,69 @@ Conference abbreviations P5: ACC, B12, B1G, SEC, PAC\cr Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC} } \value{ -\code{\link[cfbfastR:cfbd_recruiting_player]{cfbfastR::cfbd_recruiting_player()}} - A data frame with 14 variables: +\code{\link[=cfbd_recruiting_player]{cfbd_recruiting_player()}} - A data frame with 14 variables: \describe{ -\item{\code{recruit_type}}{character.} -\item{\code{year}}{integer.} -\item{\code{ranking}}{integer.} -\item{\code{name}}{character.} -\item{\code{school}}{character.} -\item{\code{committed_to}}{character.} -\item{\code{position}}{character.} -\item{\code{height}}{double.} -\item{\code{weight}}{integer.} -\item{\code{stars}}{integer.} -\item{\code{rating}}{double.} -\item{\code{city}}{character.} -\item{\code{state_province}}{character.} -\item{\code{country}}{character.} -\item{\code{hometown_info_latitude}}{character.} -\item{\code{hometown_info_longitude}}{character.} -\item{\code{hometown_info_fips_code}}{character.} +\item{\code{recruit_type}: character.}{High School, Prep School, or Junior College.} +\item{\code{year}: integer.}{Recruit class year.} +\item{\code{ranking}: integer.}{Recruit Ranking.} +\item{\code{name}: character.}{Recruit Name.} +\item{\code{school}: character.}{School recruit attended.} +\item{\code{committed_to}: character.}{School the recruit is committed to.} +\item{\code{position}: character.}{Recruit position.} +\item{\code{height}: double.}{Recruit height.} +\item{\code{weight}: integer.}{Recruit weight.} +\item{\code{stars}: integer.}{Recruit stars.} +\item{\code{rating}: double.}{247 composite rating.} +\item{\code{city}: character.}{Hometown of the recruit.} +\item{\code{state_province}: character.}{Hometown state of the recruit.} +\item{\code{country}: character.}{Hometown country of the recruit.} +\item{\code{hometown_info_latitude}: character.}{Hometown latitude.} +\item{\code{hometown_info_longitude}: character.}{Hometown longitude.} +\item{\code{hometown_info_fips_code}: character.}{Hometown FIPS code.} } -\code{\link[cfbfastR:cfbd_recruiting_position]{cfbfastR::cfbd_recruiting_position()}} - A data frame with 7 variables: +\code{\link[=cfbd_recruiting_position]{cfbd_recruiting_position()}} - A data frame with 7 variables: \describe{ -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{position_group}}{character.} -\item{\code{avg_rating}}{double.} -\item{\code{total_rating}}{double.} -\item{\code{commits}}{integer.} -\item{\code{avg_stars}}{double.} +\item{\code{team}: character.}{Recruiting team.} +\item{\code{conference}: character.}{Recruiting team conference.} +\item{\code{position_group}: character.}{Position group of the recruits.} +\item{\code{avg_rating}: double.}{Average rating of the recruits in the position group.} +\item{\code{total_rating}: double.}{Sum of the ratings of the recruits in the position group.} +\item{\code{commits}: integer.}{Number of commits in the position group.} +\item{\code{avg_stars}: double.}{Average stars of the recruits in the position group.} } -\code{\link[cfbfastR:cfbd_recruiting_team]{cfbfastR::cfbd_recruiting_team()}} - A data frame with 4 variables: +\code{\link[=cfbd_recruiting_team]{cfbd_recruiting_team()}} - A data frame with 4 variables: \describe{ -\item{\code{year}}{integer.} -\item{\code{rank}}{integer.} -\item{\code{team}}{character.} -\item{\code{points}}{character.} +\item{\code{year}: integer.}{Recruiting class year.} +\item{\code{rank}: integer.}{Team Recruiting rank.} +\item{\code{team}: character.}{Recruiting Team.} +\item{\code{points}: character.}{Team talent points.} } } \description{ -Gets CFB recruiting information for a single year with filters available for team, -recruit type, state and position. +\describe{ +\item{\code{cfbd_recruiting_player()}: Gets CFB recruiting information for a single year with filters available for team, recruit type, state and position.}{} -If only start_year is provided, function will get CFB recruiting information based -on position groups during that year for all FBS teams. +\item{\code{cfbd_recruiting_position()}: CFB Recruiting Information Position Groups.}{} -Gets CFB team recruiting ranks with filters available for year and team. -At least one of \strong{year} or \strong{team} must be specified for the function to run +\item{\code{cfbd_recruiting_team()}: CFB Recruiting Information Team Rankings.}{} +} } \details{ +Gets CFB team recruiting ranks with filters available for year and team. At least one of \strong{year} or \strong{team} must be specified for the function to run -If you would like CFB recruiting information for teams, please see the \code{\link[cfbfastR:cfbd_recruiting_team]{cfbfastR::cfbd_recruiting_team()}} function - -If you would like to get cfb recruiting information based on position groups during a -time period for all FBS teams, please see the \code{\link[cfbfastR:cfbd_recruiting_position]{cfbfastR::cfbd_recruiting_position()}} function. - If you would like CFB recruiting information for players, please -see the \code{\link[cfbfastR:cfbd_recruiting_player]{cfbfastR::cfbd_recruiting_player()}} function +see the \code{\link[=cfbd_recruiting_player]{cfbd_recruiting_player()}} function -If you would like CFB recruiting information for teams, please -see the \code{\link[cfbfastR:cfbd_recruiting_team]{cfbfastR::cfbd_recruiting_team()}} function +If you would like to get CFB recruiting information based on position groups during a +time period for all FBS teams, please see the \code{\link[=cfbd_recruiting_position]{cfbd_recruiting_position()}} function. -If you would like CFB recruiting information for players, please -see the \code{\link[cfbfastR:cfbd_recruiting_player]{cfbfastR::cfbd_recruiting_player()}} function +\code{\link[=cfbd_recruiting_player]{cfbd_recruiting_player()}} - At least one of \strong{year} or \strong{team} must be specified for the function to run -If you would like to get CFB recruiting information based on position groups during a -time period for all FBS teams, please see the \code{\link[cfbfastR:cfbd_recruiting_position]{cfbfastR::cfbd_recruiting_position()}} function. +\code{\link[=cfbd_recruiting_position]{cfbd_recruiting_position()}} - If only start_year is provided, function will get CFB recruiting information based +on position groups during that year for all FBS teams. } \examples{ \donttest{ diff --git a/man/cfbd_stats.Rd b/man/cfbd_stats.Rd index ea398a1d..52d43abb 100644 --- a/man/cfbd_stats.Rd +++ b/man/cfbd_stats.Rd @@ -99,266 +99,274 @@ Special Teams: punting, puntReturns, kicking, kickReturns} \code{\link[=cfbd_stats_game_advanced]{cfbd_stats_game_advanced()}} - A data frame with 60 variables: \describe{ -\item{\code{game_id}}{integer.} -\item{\code{week}}{integer.} -\item{\code{team}}{character.} -\item{\code{opponent}}{character.} -\item{\code{off_plays}}{integer.} -\item{\code{off_drives}}{integer.} -\item{\code{off_ppa}}{double.} -\item{\code{off_total_ppa}}{double.} -\item{\code{off_success_rate}}{double.} -\item{\code{off_explosiveness}}{double.} -\item{\code{off_power_success}}{double.} -\item{\code{off_stuff_rate}}{double.} -\item{\code{off_line_yds}}{double.} -\item{\code{off_line_yds_total}}{integer.} -\item{\code{off_second_lvl_yds}}{double.} -\item{\code{off_second_lvl_yds_total}}{integer.} -\item{\code{off_open_field_yds}}{integer.} -\item{\code{off_open_field_yds_total}}{integer.} -\item{\code{off_standard_downs_ppa}}{double.} -\item{\code{off_standard_downs_success_rate}}{double.} -\item{\code{off_standard_downs_explosiveness}}{double.} -\item{\code{off_passing_downs_ppa}}{double.} -\item{\code{off_passing_downs_success_rate}}{double.} -\item{\code{off_passing_downs_explosiveness}}{double.} -\item{\code{off_rushing_plays_ppa}}{double.} -\item{\code{off_rushing_plays_total_ppa}}{double.} -\item{\code{off_rushing_plays_success_rate}}{double.} -\item{\code{off_rushing_plays_explosiveness}}{double.} -\item{\code{off_passing_plays_ppa}}{double.} -\item{\code{off_passing_plays_total_ppa}}{double.} -\item{\code{off_passing_plays_success_rate}}{double.} -\item{\code{off_passing_plays_explosiveness}}{double.} -\item{\code{def_plays}}{integer.} -\item{\code{def_drives}}{integer.} -\item{\code{def_ppa}}{double.} -\item{\code{def_total_ppa}}{double.} -\item{\code{def_success_rate}}{double.} -\item{\code{def_explosiveness}}{double.} -\item{\code{def_power_success}}{double.} -\item{\code{def_stuff_rate}}{double.} -\item{\code{def_line_yds}}{double.} -\item{\code{def_line_yds_total}}{integer.} -\item{\code{def_second_lvl_yds}}{double.} -\item{\code{def_second_lvl_yds_total}}{integer.} -\item{\code{def_open_field_yds}}{double.} -\item{\code{def_open_field_yds_total}}{integer.} -\item{\code{def_standard_downs_ppa}}{double.} -\item{\code{def_standard_downs_success_rate}}{double.} -\item{\code{def_standard_downs_explosiveness}}{double.} -\item{\code{def_passing_downs_ppa}}{double.} -\item{\code{def_passing_downs_success_rate}}{double.} -\item{\code{def_passing_downs_explosiveness}}{double.} -\item{\code{def_rushing_plays_ppa}}{double.} -\item{\code{def_rushing_plays_total_ppa}}{double.} -\item{\code{def_rushing_plays_success_rate}}{double.} -\item{\code{def_rushing_plays_explosiveness}}{double.} -\item{\code{def_passing_plays_ppa}}{double.} -\item{\code{def_passing_plays_total_ppa}}{double.} -\item{\code{def_passing_plays_success_rate}}{double.} -\item{\code{def_passing_plays_explosiveness}}{double.} +\item{\code{game_id}: integer.}{.} +\item{\code{week}: integer.}{.} +\item{\code{team}: character.}{.} +\item{\code{opponent}: character.}{.} +\item{\code{off_plays}: integer.}{.} +\item{\code{off_drives}: integer.}{.} +\item{\code{off_ppa}: double.}{.} +\item{\code{off_total_ppa}: double.}{.} +\item{\code{off_success_rate}: double.}{.} +\item{\code{off_explosiveness}: double.}{.} +\item{\code{off_power_success}: double.}{.} +\item{\code{off_stuff_rate}: double.}{.} +\item{\code{off_line_yds}: double.}{.} +\item{\code{off_line_yds_total}: integer.}{.} +\item{\code{off_second_lvl_yds}: double.}{.} +\item{\code{off_second_lvl_yds_total}: integer.}{.} +\item{\code{off_open_field_yds}: integer.}{.} +\item{\code{off_open_field_yds_total}: integer.}{.} +\item{\code{off_standard_downs_ppa}: double.}{.} +\item{\code{off_standard_downs_success_rate}: double.}{.} +\item{\code{off_standard_downs_explosiveness}: double.}{.} +\item{\code{off_passing_downs_ppa}: double.}{.} +\item{\code{off_passing_downs_success_rate}: double.}{.} +\item{\code{off_passing_downs_explosiveness}: double.}{.} +\item{\code{off_rushing_plays_ppa}: double.}{.} +\item{\code{off_rushing_plays_total_ppa}: double.}{.} +\item{\code{off_rushing_plays_success_rate}: double.}{.} +\item{\code{off_rushing_plays_explosiveness}: double.}{.} +\item{\code{off_passing_plays_ppa}: double.}{.} +\item{\code{off_passing_plays_total_ppa}: double.}{.} +\item{\code{off_passing_plays_success_rate}: double.}{.} +\item{\code{off_passing_plays_explosiveness}: double.}{.} +\item{\code{def_plays}: integer.}{.} +\item{\code{def_drives}: integer.}{.} +\item{\code{def_ppa}: double.}{.} +\item{\code{def_total_ppa}: double.}{.} +\item{\code{def_success_rate}: double.}{.} +\item{\code{def_explosiveness}: double.}{.} +\item{\code{def_power_success}: double.}{.} +\item{\code{def_stuff_rate}: double.}{.} +\item{\code{def_line_yds}: double.}{.} +\item{\code{def_line_yds_total}: integer.}{.} +\item{\code{def_second_lvl_yds}: double.}{.} +\item{\code{def_second_lvl_yds_total}: integer.}{.} +\item{\code{def_open_field_yds}: double.}{.} +\item{\code{def_open_field_yds_total}: integer.}{.} +\item{\code{def_standard_downs_ppa}: double.}{.} +\item{\code{def_standard_downs_success_rate}: double.}{.} +\item{\code{def_standard_downs_explosiveness}: double.}{.} +\item{\code{def_passing_downs_ppa}: double.}{.} +\item{\code{def_passing_downs_success_rate}: double.}{.} +\item{\code{def_passing_downs_explosiveness}: double.}{.} +\item{\code{def_rushing_plays_ppa}: double.}{.} +\item{\code{def_rushing_plays_total_ppa}: double.}{.} +\item{\code{def_rushing_plays_success_rate}: double.}{.} +\item{\code{def_rushing_plays_explosiveness}: double.}{.} +\item{\code{def_passing_plays_ppa}: double.}{.} +\item{\code{def_passing_plays_total_ppa}: double.}{.} +\item{\code{def_passing_plays_success_rate}: double.}{.} +\item{\code{def_passing_plays_explosiveness}: double.}{.} } \code{\link[=cfbd_stats_season_advanced]{cfbd_stats_season_advanced()}} - A data frame with 79 variables: \describe{ -\item{\code{season}}{integer.} -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{off_plays}}{integer.} -\item{\code{off_drives}}{integer.} -\item{\code{off_ppa}}{double.} -\item{\code{off_total_ppa}}{double.} -\item{\code{off_success_rate}}{double.} -\item{\code{off_explosiveness}}{double.} -\item{\code{off_power_success}}{double.} -\item{\code{off_stuff_rate}}{double.} -\item{\code{off_line_yds}}{double.} -\item{\code{off_line_yds_total}}{integer.} -\item{\code{off_second_lvl_yds}}{double.} -\item{\code{off_second_lvl_yds_total}}{integer.} -\item{\code{off_open_field_yds}}{double.} -\item{\code{off_open_field_yds_total}}{integer.} -\item{\code{off_pts_per_opp}}{double.} -\item{\code{off_field_pos_avg_start}}{double.} -\item{\code{off_field_pos_avg_predicted_points}}{double.} -\item{\code{off_havoc_total}}{double.} -\item{\code{off_havoc_front_seven}}{double.} -\item{\code{off_havoc_db}}{double.} -\item{\code{off_standard_downs_rate}}{double.} -\item{\code{off_standard_downs_ppa}}{double.} -\item{\code{off_standard_downs_success_rate}}{double.} -\item{\code{off_standard_downs_explosiveness}}{double.} -\item{\code{off_passing_downs_rate}}{double.} -\item{\code{off_passing_downs_ppa}}{double.} -\item{\code{off_passing_downs_success_rate}}{double.} -\item{\code{off_passing_downs_explosiveness}}{double.} -\item{\code{off_rushing_plays_rate}}{double.} -\item{\code{off_rushing_plays_ppa}}{double.} -\item{\code{off_rushing_plays_total_ppa}}{double.} -\item{\code{off_rushing_plays_success_rate}}{double.} -\item{\code{off_rushing_plays_explosiveness}}{double.} -\item{\code{off_passing_plays_rate}}{double.} -\item{\code{off_passing_plays_ppa}}{double.} -\item{\code{off_passing_plays_total_ppa}}{double.} -\item{\code{off_passing_plays_success_rate}}{double.} -\item{\code{off_passing_plays_explosiveness}}{double.} -\item{\code{def_plays}}{integer.} -\item{\code{def_drives}}{integer.} -\item{\code{def_ppa}}{double.} -\item{\code{def_total_ppa}}{double.} -\item{\code{def_success_rate}}{double.} -\item{\code{def_explosiveness}}{double.} -\item{\code{def_power_success}}{double.} -\item{\code{def_stuff_rate}}{double.} -\item{\code{def_line_yds}}{double.} -\item{\code{def_line_yds_total}}{integer.} -\item{\code{def_second_lvl_yds}}{double.} -\item{\code{def_second_lvl_yds_total}}{integer.} -\item{\code{def_open_field_yds}}{double.} -\item{\code{def_open_field_yds_total}}{integer.} -\item{\code{def_pts_per_opp}}{double.} -\item{\code{def_field_pos_avg_start}}{integer.} -\item{\code{def_field_pos_avg_predicted_points}}{double.} -\item{\code{def_havoc_total}}{double.} -\item{\code{def_havoc_front_seven}}{double.} -\item{\code{def_havoc_db}}{double.} -\item{\code{def_standard_downs_rate}}{double.} -\item{\code{def_standard_downs_ppa}}{double.} -\item{\code{def_standard_downs_success_rate}}{double.} -\item{\code{def_standard_downs_explosiveness}}{double.} -\item{\code{def_passing_downs_rate}}{double.} -\item{\code{def_passing_downs_ppa}}{double.} -\item{\code{def_passing_downs_total_ppa}}{double.} -\item{\code{def_passing_downs_success_rate}}{double.} -\item{\code{def_passing_downs_explosiveness}}{double.} -\item{\code{def_rushing_plays_rate}}{double.} -\item{\code{def_rushing_plays_ppa}}{double.} -\item{\code{def_rushing_plays_total_ppa}}{double.} -\item{\code{def_rushing_plays_success_rate}}{double.} -\item{\code{def_rushing_plays_explosiveness}}{double.} -\item{\code{def_passing_plays_rate}}{double.} -\item{\code{def_passing_plays_ppa}}{double.} -\item{\code{def_passing_plays_success_rate}}{double.} -\item{\code{def_passing_plays_explosiveness}}{double.} +\item{\code{season}: integer.}{.} +\item{\code{team}: character.}{.} +\item{\code{conference}: character.}{.} +\item{\code{off_plays}: integer.}{.} +\item{\code{off_drives}: integer.}{.} +\item{\code{off_ppa}: double.}{.} +\item{\code{off_total_ppa}: double.}{.} +\item{\code{off_success_rate}: double.}{.} +\item{\code{off_explosiveness}: double.}{.} +\item{\code{off_power_success}: double.}{.} +\item{\code{off_stuff_rate}: double.}{.} +\item{\code{off_line_yds}: double.}{.} +\item{\code{off_line_yds_total}: integer.}{.} +\item{\code{off_second_lvl_yds}: double.}{.} +\item{\code{off_second_lvl_yds_total}: integer.}{.} +\item{\code{off_open_field_yds}: double.}{.} +\item{\code{off_open_field_yds_total}: integer.}{.} +\item{\code{off_pts_per_opp}: double.}{.} +\item{\code{off_field_pos_avg_start}: double.}{.} +\item{\code{off_field_pos_avg_predicted_points}: double.}{.} +\item{\code{off_havoc_total}: double.}{.} +\item{\code{off_havoc_front_seven}: double.}{.} +\item{\code{off_havoc_db}: double.}{.} +\item{\code{off_standard_downs_rate}: double.}{.} +\item{\code{off_standard_downs_ppa}: double.}{.} +\item{\code{off_standard_downs_success_rate}: double.}{.} +\item{\code{off_standard_downs_explosiveness}: double.}{.} +\item{\code{off_passing_downs_rate}: double.}{.} +\item{\code{off_passing_downs_ppa}: double.}{.} +\item{\code{off_passing_downs_success_rate}: double.}{.} +\item{\code{off_passing_downs_explosiveness}: double.}{.} +\item{\code{off_rushing_plays_rate}: double.}{.} +\item{\code{off_rushing_plays_ppa}: double.}{.} +\item{\code{off_rushing_plays_total_ppa}: double.}{.} +\item{\code{off_rushing_plays_success_rate}: double.}{.} +\item{\code{off_rushing_plays_explosiveness}: double.}{.} +\item{\code{off_passing_plays_rate}: double.}{.} +\item{\code{off_passing_plays_ppa}: double.}{.} +\item{\code{off_passing_plays_total_ppa}: double.}{.} +\item{\code{off_passing_plays_success_rate}: double.}{.} +\item{\code{off_passing_plays_explosiveness}: double.}{.} +\item{\code{def_plays}: integer.}{.} +\item{\code{def_drives}: integer.}{.} +\item{\code{def_ppa}: double.}{.} +\item{\code{def_total_ppa}: double.}{.} +\item{\code{def_success_rate}: double.}{.} +\item{\code{def_explosiveness}: double.}{.} +\item{\code{def_power_success}: double.}{.} +\item{\code{def_stuff_rate}: double.}{.} +\item{\code{def_line_yds}: double.}{.} +\item{\code{def_line_yds_total}: integer.}{.} +\item{\code{def_second_lvl_yds}: double.}{.} +\item{\code{def_second_lvl_yds_total}: integer.}{.} +\item{\code{def_open_field_yds}: double.}{.} +\item{\code{def_open_field_yds_total}: integer.}{.} +\item{\code{def_pts_per_opp}: double.}{.} +\item{\code{def_field_pos_avg_start}: integer.}{.} +\item{\code{def_field_pos_avg_predicted_points}: double.}{.} +\item{\code{def_havoc_total}: double.}{.} +\item{\code{def_havoc_front_seven}: double.}{.} +\item{\code{def_havoc_db}: double.}{.} +\item{\code{def_standard_downs_rate}: double.}{.} +\item{\code{def_standard_downs_ppa}: double.}{.} +\item{\code{def_standard_downs_success_rate}: double.}{.} +\item{\code{def_standard_downs_explosiveness}: double.}{.} +\item{\code{def_passing_downs_rate}: double.}{.} +\item{\code{def_passing_downs_ppa}: double.}{.} +\item{\code{def_passing_downs_total_ppa}: double.}{.} +\item{\code{def_passing_downs_success_rate}: double.}{.} +\item{\code{def_passing_downs_explosiveness}: double.}{.} +\item{\code{def_rushing_plays_rate}:double.}{.} +\item{\code{def_rushing_plays_ppa}:double.}{.} +\item{\code{def_rushing_plays_total_ppa}:double.}{.} +\item{\code{def_rushing_plays_success_rate}:double.}{.} +\item{\code{def_rushing_plays_explosiveness}:double.}{.} +\item{\code{def_passing_plays_rate}:double.}{.} +\item{\code{def_passing_plays_ppa}:double.}{.} +\item{\code{def_passing_plays_success_rate}:double.}{.} +\item{\code{def_passing_plays_explosiveness}:double.}{.} } \code{\link[=cfbd_stats_season_player]{cfbd_stats_season_player()}} - A data frame with 59 variables: \describe{ -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{athlete_id}}{character.} -\item{\code{player}}{character.} -\item{\code{category}}{character.} -\item{\code{passing_completions}}{double.} -\item{\code{passing_att}}{double.} -\item{\code{passing_pct}}{double.} -\item{\code{passing_yds}}{double.} -\item{\code{passing_td}}{double.} -\item{\code{passing_int}}{double.} -\item{\code{passing_ypa}}{double.} -\item{\code{rushing_car}}{double.} -\item{\code{rushing_yds}}{double.} -\item{\code{rushing_td}}{double.} -\item{\code{rushing_ypc}}{double.} -\item{\code{rushing_long}}{double.} -\item{\code{receiving_rec}}{double.} -\item{\code{receiving_yds}}{double.} -\item{\code{receiving_td}}{double.} -\item{\code{receiving_ypr}}{double.} -\item{\code{receiving_long}}{double.} -\item{\code{fumbles_fum}}{double.} -\item{\code{fumbles_rec}}{double.} -\item{\code{fumbles_lost}}{double.} -\item{\code{defensive_solo}}{double.} -\item{\code{defensive_tot}}{double.} -\item{\code{defensive_tfl}}{double.} -\item{\code{defensive_sacks}}{double.} -\item{\code{defensive_qb_hur}}{double.} -\item{\code{interceptions_int}}{double.} -\item{\code{interceptions_yds}}{double.} -\item{\code{interceptions_avg}}{double.} -\item{\code{interceptions_td}}{double.} -\item{\code{defensive_pd}}{double.} -\item{\code{defensive_td}}{double.} -\item{\code{kicking_fgm}}{double.} -\item{\code{kicking_fga}}{double.} -\item{\code{kicking_pct}}{double.} -\item{\code{kicking_xpa}}{double.} -\item{\code{kicking_xpm}}{double.} -\item{\code{kicking_pts}}{double.} -\item{\code{kicking_long}}{double.} -\item{\code{kick_returns_no}}{double.} -\item{\code{kick_returns_yds}}{double.} -\item{\code{kick_returns_avg}}{double.} -\item{\code{kick_returns_td}}{double.} -\item{\code{kick_returns_long}}{double.} -\item{\code{punting_no}}{double.} -\item{\code{punting_yds}}{double.} -\item{\code{punting_ypp}}{double.} -\item{\code{punting_long}}{double.} -\item{\code{punting_in_20}}{double.} -\item{\code{punting_tb}}{double.} -\item{\code{punt_returns_no}}{double.} -\item{\code{punt_returns_yds}}{double.} -\item{\code{punt_returns_avg}}{double.} -\item{\code{punt_returns_td}}{double.} -\item{\code{punt_returns_long}}{double.} +\item{\code{team}: character.}{.} +\item{\code{conference}: character.}{.} +\item{\code{athlete_id}: character.}{.} +\item{\code{player}: character.}{.} +\item{\code{category}: character.}{.} +\item{\code{passing_completions}: double.}{.} +\item{\code{passing_att}: double.}{.} +\item{\code{passing_pct}: double.}{.} +\item{\code{passing_yds}: double.}{.} +\item{\code{passing_td}: double.}{.} +\item{\code{passing_int}: double.}{.} +\item{\code{passing_ypa}: double.}{.} +\item{\code{rushing_car}: double.}{.} +\item{\code{rushing_yds}: double.}{.} +\item{\code{rushing_td}: double.}{.} +\item{\code{rushing_ypc}: double.}{.} +\item{\code{rushing_long}: double.}{.} +\item{\code{receiving_rec}: double.}{.} +\item{\code{receiving_yds}: double.}{.} +\item{\code{receiving_td}: double.}{.} +\item{\code{receiving_ypr}: double.}{.} +\item{\code{receiving_long}: double.}{.} +\item{\code{fumbles_fum}: double.}{.} +\item{\code{fumbles_rec}: double.}{.} +\item{\code{fumbles_lost}: double.}{.} +\item{\code{defensive_solo}: double.}{.} +\item{\code{defensive_tot}: double.}{.} +\item{\code{defensive_tfl}: double.}{.} +\item{\code{defensive_sacks}: double.}{.} +\item{\code{defensive_qb_hur}: double.}{.} +\item{\code{interceptions_int}: double.}{.} +\item{\code{interceptions_yds}: double.}{.} +\item{\code{interceptions_avg}: double.}{.} +\item{\code{interceptions_td}: double.}{.} +\item{\code{defensive_pd}: double.}{.} +\item{\code{defensive_td}: double.}{.} +\item{\code{kicking_fgm}: double.}{.} +\item{\code{kicking_fga}: double.}{.} +\item{\code{kicking_pct}: double.}{.} +\item{\code{kicking_xpa}: double.}{.} +\item{\code{kicking_xpm}: double.}{.} +\item{\code{kicking_pts}: double.}{.} +\item{\code{kicking_long}: double.}{.} +\item{\code{kick_returns_no}: double.}{.} +\item{\code{kick_returns_yds}: double.}{.} +\item{\code{kick_returns_avg}: double.}{.} +\item{\code{kick_returns_td}: double.}{.} +\item{\code{kick_returns_long}: double.}{.} +\item{\code{punting_no}: double.}{.} +\item{\code{punting_yds}: double.}{.} +\item{\code{punting_ypp}: double.}{.} +\item{\code{punting_long}: double.}{.} +\item{\code{punting_in_20}: double.}{.} +\item{\code{punting_tb}: double.}{.} +\item{\code{punt_returns_no}: double.}{.} +\item{\code{punt_returns_yds}: double.}{.} +\item{\code{punt_returns_avg}: double.}{.} +\item{\code{punt_returns_td}: double.}{.} +\item{\code{punt_returns_long}: double.}{.} } \code{\link[=cfbd_stats_season_team]{cfbd_stats_season_team()}} - A data frame with 46 variables: \describe{ -\item{\code{games}}{integer.} -\item{\code{team}}{character.} -\item{\code{conference}}{character.} -\item{\code{games}}{integer.} -\item{\code{time_of_poss_total}}{integer.} -\item{\code{time_of_poss_pg}}{double.} -\item{\code{pass_comps}}{integer.} -\item{\code{pass_atts}}{integer.} -\item{\code{completion_pct}}{double.} -\item{\code{net_pass_yds}}{integer.} -\item{\code{pass_ypa}}{double.} -\item{\code{pass_ypr}}{double.} -\item{\code{pass_TDs}}{integer.} -\item{\code{interceptions}}{integer.} -\item{\code{int_pct}}{double.} -\item{\code{rush_atts}}{integer.} -\item{\code{rush_yds}}{integer.} -\item{\code{rush_TDs}}{integer.} -\item{\code{rush_ypc}}{double.} -\item{\code{total_yds}}{integer.} -\item{\code{fumbles_lost}}{integer.} -\item{\code{turnovers}}{integer.} -\item{\code{turnovers_pg}}{double.} -\item{\code{first_downs}}{integer.} -\item{\code{third_downs}}{integer.} -\item{\code{third_down_convs}}{integer.} -\item{\code{third_conv_rate}}{double.} -\item{\code{fourth_down_convs}}{integer.} -\item{\code{fourth_downs}}{integer.} -\item{\code{fourth_conv_rate}}{double.} -\item{\code{penalties}}{integer.} -\item{\code{penalty_yds}}{integer.} -\item{\code{penalties_pg}}{double.} -\item{\code{penalty_yds_pg}}{double.} -\item{\code{yards_per_penalty}}{double.} -\item{\code{kick_returns}}{integer.} -\item{\code{kick_return_yds}}{integer.} -\item{\code{kick_return_TDs}}{integer.} -\item{\code{kick_return_avg}}{double.} -\item{\code{punt_returns}}{integer.} -\item{\code{punt_return_yds}}{integer.} -\item{\code{punt_return_TDs}}{integer.} -\item{\code{punt_return_avg}}{double.} -\item{\code{passes_intercepted}}{integer.} -\item{\code{passes_intercepted_yds}}{integer.} -\item{\code{passes_intercepted_TDs}}{integer.} +\item{\code{games}: integer.}{.} +\item{\code{team}: character.}{.} +\item{\code{conference}: character.}{.} +\item{\code{games}: integer.}{.} +\item{\code{time_of_poss_total}: integer.}{.} +\item{\code{time_of_poss_pg}: double.}{.} +\item{\code{pass_comps}: integer.}{.} +\item{\code{pass_atts}: integer.}{.} +\item{\code{completion_pct}: double.}{.} +\item{\code{net_pass_yds}: integer.}{.} +\item{\code{pass_ypa}: double.}{.} +\item{\code{pass_ypr}: double.}{.} +\item{\code{pass_TDs}: integer.}{.} +\item{\code{interceptions}: integer.}{.} +\item{\code{int_pct}: double.}{.} +\item{\code{rush_atts}: integer.}{.} +\item{\code{rush_yds}: integer.}{.} +\item{\code{rush_TDs}: integer.}{.} +\item{\code{rush_ypc}: double.}{.} +\item{\code{total_yds}: integer.}{.} +\item{\code{fumbles_lost}: integer.}{.} +\item{\code{turnovers}: integer.}{.} +\item{\code{turnovers_pg}: double.}{.} +\item{\code{first_downs}: integer.}{.} +\item{\code{third_downs}: integer.}{.} +\item{\code{third_down_convs}: integer.}{.} +\item{\code{third_conv_rate}: double.}{.} +\item{\code{fourth_down_convs}: integer.}{.} +\item{\code{fourth_downs}: integer.}{.} +\item{\code{fourth_conv_rate}: double.}{.} +\item{\code{penalties}: integer.}{.} +\item{\code{penalty_yds}: integer.}{.} +\item{\code{penalties_pg}: double.}{.} +\item{\code{penalty_yds_pg}: double.}{.} +\item{\code{yards_per_penalty}: double.}{.} +\item{\code{kick_returns}: integer.}{.} +\item{\code{kick_return_yds}: integer.}{.} +\item{\code{kick_return_TDs}: integer.}{.} +\item{\code{kick_return_avg}: double.}{.} +\item{\code{punt_returns}: integer.}{.} +\item{\code{punt_return_yds}: integer.}{.} +\item{\code{punt_return_TDs}: integer.}{.} +\item{\code{punt_return_avg}: double.}{.} +\item{\code{passes_intercepted}: integer.}{.} +\item{\code{passes_intercepted_yds}: integer.}{.} +\item{\code{passes_intercepted_TDs}: integer.}{.} } } \description{ -This function identifies all Stats Categories identified in the regular stats endpoint. +\describe{ +\item{\code{cfbd_stats_categories()}: College Football Mapping for Stats Categories}{.} +\item{\code{cfbd_stats_season_team()}: Get Season Statistics by Team}{.} +\item{\code{cfbd_stats_season_advanced()}: Get Season Advanced Statistics by Team}{.} +\item{\code{cfbd_stats_game_advanced()}: Get Game Advanced Stats}{.} +\item{\code{cfbd_stats_season_player()}: Get Season Statistics by Player}{.} +} + +\code{\link[=cfbd_stats_categories]{cfbd_stats_categories()}} This function identifies all Stats Categories identified in the regular stats endpoint. } \examples{ \donttest{ diff --git a/man/cfbd_teams.Rd b/man/cfbd_teams.Rd index e2b96ae1..76132b62 100644 --- a/man/cfbd_teams.Rd +++ b/man/cfbd_teams.Rd @@ -70,105 +70,101 @@ If year is left blank while only_fbs is TRUE, then will return values for most c \item{team}{(\emph{String} optional): Team, select a valid team in D-I football} } \value{ -\code{\link[cfbfastR:cfbd_team_info]{cfbfastR::cfbd_team_info()}} - A data frame with 12 variables: +\code{\link[=cfbd_team_info]{cfbd_team_info()}} - A data frame with 12 variables: \describe{ -\item{\code{team_id}}{integer.} -\item{\code{school}}{character.} -\item{\code{mascot}}{character.} -\item{\code{abbreviation}}{character.} -\item{\code{alt_name1}}{character.} -\item{\code{alt_name2}}{character.} -\item{\code{alt_name3}}{character.} -\item{\code{conference}}{character.} -\item{\code{division}}{character.} -\item{\code{color}}{character.} -\item{\code{alt_color}}{character.} -\item{\code{logo_1}}{character.} -\item{\code{logo_2}}{character.} -\item{\code{venue_id}}{character.} -\item{\code{venue_name}}{character.} -\item{\code{city}}{character.} -\item{\code{state}}{character.} -\item{\code{zip}}{character.} -\item{\code{country_code}}{character.} -\item{\code{timezone}}{character.} -\item{\code{latitude}}{character.} -\item{\code{longitude}}{character.} -\item{\code{elevation}}{character.} -\item{\code{capacity}}{character.} -\item{\code{year_constructed}}{character.} -\item{\code{grass}}{character.} -\item{\code{dome}}{character.} -} - -\code{\link[cfbfastR:cfbd_team_matchup_records]{cfbfastR::cfbd_team_matchup_records()}} - A data frame with 7 variables: +\item{\code{team_id}: integer.}{Referencing team id.} +\item{\code{school}: character.}{Team name.} +\item{\code{mascot}: character.}{Team mascot.} +\item{\code{abbreviation}: character.}{Team abbreviations.} +\item{\code{alt_name1}: character.}{Team alternate name 1 (as it appears in \code{play_text}).} +\item{\code{alt_name2}: character.}{Team alternate name 2 (as it appears in \code{play_text}).} +\item{\code{alt_name3}: character.}{Team alternate name 3 (as it appears in \code{play_text}).} +\item{\code{conference}: character.}{Conference of team.} +\item{\code{division}: character.}{Division of team within the conference.} +\item{\code{color}: character.}{Team color (primary).} +\item{\code{alt_color}: character.}{Team color (alternate).} +\item{\code{logos}: character.}{Team logos.} +\item{\code{venue_id}: character.}{Referencing venue id.} +\item{\code{venue_name}: character.}{Stadium name.} +\item{\code{city}: character.}{Team/venue city.} +\item{\code{state}: character.}{Team/venue state.} +\item{\code{zip}: character.}{Team/venue zip code (someone double check Miami (FL) on if they're in the same zip code).} +\item{\code{country_code}: character.}{Team/venue country code.} +\item{\code{timezone}: character.}{Team/venue timezone.} +\item{\code{latitude}: character.}{Venue latitude.} +\item{\code{longitude}: character.}{Venue longitude.} +\item{\code{elevation}: character.}{Venue elevation.} +\item{\code{capacity}: character.}{Venue capacity.} +\item{\code{year_constructed}: character.}{Year the venue was constructed.} +\item{\code{grass}: character.}{TRUE/FALSE response on whether the field is grass or not (oh, and there are so many others).} +\item{\code{dome}: character.}{TRUE/FALSE flag for if the venue is a domed stadium.} +} + +\code{\link[=cfbd_team_matchup_records]{cfbd_team_matchup_records()}} - A data frame with 7 variables: \describe{ -\item{\code{start_year}}{character.} -\item{\code{end_year}}{character.} -\item{\code{team1}}{character.} -\item{\code{team1_wins}}{character.} -\item{\code{team2}}{character.} -\item{\code{team2_wins}}{character.} -\item{\code{ties}}{character.} +\item{\code{start_year}: character.}{Span starting year.} +\item{\code{end_year}: character.}{Span ending year.} +\item{\code{team1}: character.}{First team selected in query.} +\item{\code{team1_wins}: character.}{First team wins in series against \code{team2}.} +\item{\code{team2}: character.}{Second team selected in query.} +\item{\code{team2_wins}: character.}{Second team wins in series against \code{team1}.} +\item{\code{ties}: character.}{Number of ties in the series.} } -\code{\link[cfbfastR:cfbd_team_matchup]{cfbfastR::cfbd_team_matchup()}} - A data frame with 11 variables: +\link{cfbd_team_matchup} - A data frame with 11 variables: \describe{ -\item{\code{season}}{integer.} -\item{\code{week}}{integer.} -\item{\code{season_type}}{character.} -\item{\code{date}}{character.} -\item{\code{neutral_site}}{logical.} -\item{\code{venue}}{character.} -\item{\code{home_team}}{character.} -\item{\code{home_score}}{integer.} -\item{\code{away_team}}{character.} -\item{\code{away_score}}{integer.} -\item{\code{winner}}{character.} -} - -\code{\link[cfbfastR:cfbd_team_roster]{cfbfastR::cfbd_team_roster()}} - A data frame with 12 variables: +\item{\code{season}: integer.}{Season the game took place.} +\item{\code{week}: integer.}{Game week of the season.} +\item{\code{season_type}: character.}{Season type of the game.} +\item{\code{date}: character.}{Game date.} +\item{\code{neutral_site}: logical.}{TRUE/FALSE flag for if the game took place at a neutral site.} +\item{\code{venue}: character.}{Stadium name.} +\item{\code{home_team}: character.}{Home team of the game.} +\item{\code{home_score}: integer.}{Home score in the game.} +\item{\code{away_team}: character.}{Away team of the game.} +\item{\code{away_score}: integer.}{Away score in the game.} +\item{\code{winner}: character.}{Winner of the matchup.} +} + +\code{\link[=cfbd_team_roster]{cfbd_team_roster()}} - A data frame with 12 variables: \describe{ -\item{\code{athlete_id}}{character.} -\item{\code{first_name}}{character.} -\item{\code{last_name}}{character.} -\item{\code{team}}{character.} -\item{\code{weight}}{integer.} -\item{\code{height}}{integer.} -\item{\code{jersey}}{integer.} -\item{\code{year}}{integer.} -\item{\code{position}}{character.} -\item{\code{home_city}}{character.} -\item{\code{home_state}}{character.} -\item{\code{home_country}}{character.} -\item{\code{home_latitude}}{numeric.} -\item{\code{home_longitude}}{number.} -\item{\code{home_county_fips}}{integer.} -} - -\code{\link[cfbfastR:cfbd_team_talent]{cfbfastR::cfbd_team_talent()}} - A data frame with 3 variables: +\item{\code{athlete_id}: character.}{Referencing athlete id.} +\item{\code{first_name}: character.}{Athlete first name.} +\item{\code{last_name}: character.}{Athlete last name.} +\item{\code{team}: character.}{Team name.} +\item{\code{weight}: integer.}{Athlete weight.} +\item{\code{height}: integer.}{Athlete height.} +\item{\code{jersey}: integer.}{Athlete jersey number.} +\item{\code{year}: integer.}{Athlete year.} +\item{\code{position}: character.}{Athlete position.} +\item{\code{home_city}: character.}{Hometown of the athlete.} +\item{\code{home_state}: character.}{Hometown state of the athlete.} +\item{\code{home_country}: character.}{Hometown country of the athlete.} +\item{\code{home_latitude}: numeric.}{Hometown latitude.} +\item{\code{home_longitude}: number.}{Hometown longitude.} +\item{\code{home_county_fips}: integer.}{Hometown FIPS code.} +} + +\code{\link[=cfbd_team_talent]{cfbd_team_talent()}} - A data frame with 3 variables: \describe{ -\item{\code{year}}{integer.} -\item{\code{school}}{character.} -\item{\code{talent}}{double.} +\item{\code{year}: integer.}{Season for the talent rating.} +\item{\code{school}: character.}{Team name.} +\item{\code{talent}: double.}{Overall roster talent points (as determined by 247Sports).} } } \description{ -CFBD Teams Endpoint +\describe{ +\item{\code{cfbd_team_info()}: Team Info Lookup}{.} +\item{\code{cfbd_team_matchup_records()}: Get matchup history records between two teams.}{.} +\item{\code{cfbd_team_matchup()}: Get matchup history between two teams.}{.} +\item{\code{cfbd_team_roster()}: Get a team's full roster by year.}{.} +\item{\code{cfbd_team_talent()}: Get composite team talent rankings for all teams in a given year}{.} +} +\subsection{Team Info Lookup}{ -Team Info Lookup Lists all teams in conference or all D-I teams if conference is left NULL -Current support only for D-I - -Get matchup history records between two teams. - -Get matchup history between two teams. - -Team Roster -Get a teams full roster by year. If team is not selected, API returns rosters for every team from the selected year. - -Get composite team talent rankings for all teams in a given year -Extracts team talent composite as sourced from 247 rankings +Currently, support is only provided for D-I +} } \examples{ \donttest{ @@ -178,7 +174,6 @@ cfbd_team_info(conference = "Ind") cfbd_team_info(year = 2019) } - \donttest{ cfbd_team_matchup_records("Texas", "Oklahoma") diff --git a/man/cfbd_venues.Rd b/man/cfbd_venues.Rd index d5f65c07..8662c042 100644 --- a/man/cfbd_venues.Rd +++ b/man/cfbd_venues.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/cfbd_venues.R \name{cfbd_venues} \alias{cfbd_venues} -\title{CFB Venue Information} +\title{CFBD Venues Endpoint} \source{ \url{https://api.collegefootballdata.com/venues} } @@ -10,31 +10,34 @@ cfbd_venues() } \value{ -A data frame with 335 rows and 13 variables: +A data frame with 337 rows and 13 variables: \describe{ -\item{\code{venue_id}}{integer.} -\item{\code{name}}{character.} -\item{\code{capacity}}{integer.} -\item{\code{grass}}{logical.} -\item{\code{city}}{character.} -\item{\code{state}}{character.} -\item{\code{zip}}{character.} -\item{\code{country_code}}{character.} -\item{\code{location}}{list.} -\item{\code{elevation}}{character.} -\item{\code{year_constructed}}{integer.} -\item{\code{dome}}{logical.} -\item{\code{timezone}}{character.} +\item{\code{venue_id}:integer.}{Referencing venue ID.} +\item{\code{name}:character.}{Venue name.} +\item{\code{capacity}:integer.}{Stadium capacity.} +\item{\code{grass}:logical.}{TRUE/FALSE response on whether the field is grass or not (oh, and there are so many others).} +\item{\code{city}:character.}{Venue city.} +\item{\code{state}:character.}{Venue state.} +\item{\code{zip}:character.}{Venue zip.} +\item{\code{country_code}:character.}{Venue country code.} +\item{\code{location}:list.}{Venue location.} +\item{\code{elevation}:character.}{Venue elevation.} +\item{\code{year_constructed}:integer.}{Year in which the venue was constructed.} +\item{\code{dome}:logical.}{TRUE/FALSE response to whether the venue has a dome or not.} +\item{\code{timezone}:character.}{Time zone in which the venue resides (i.e. Eastern Time -> "America/New York").} } } \description{ Pulls all college football venues and data on capacity, grass, city/state, location, -elevation, dome, timezone and construction year +elevation, dome, timezone and construction year. +} +\details{ +CFB Venue Information\if{html}{\out{
}}\preformatted{ cfbd_venues() +}\if{html}{\out{
}} } \examples{ \donttest{ -cfbd_venues() + cfbd_venues() } - } \keyword{Venues} diff --git a/man/check_github.Rd b/man/check_github.Rd index cb1aa6d6..1ee05576 100644 --- a/man/check_github.Rd +++ b/man/check_github.Rd @@ -17,6 +17,6 @@ Check latest GitHub version of R package } \examples{ \dontrun{ - check_github('saiemgilani/cfbfastR') + cfbfastR:::check_github('saiemgilani/cfbfastR') } } diff --git a/man/clean_drive_dat.Rd b/man/clean_drive_dat.Rd deleted file mode 100644 index fbb3bf08..00000000 --- a/man/clean_drive_dat.Rd +++ /dev/null @@ -1,52 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/cfbd_pbp_data.R -\name{clean_drive_dat} -\alias{clean_drive_dat} -\title{Create new Drive results and id data -Cleans Play-by-Play data pulled from the API's raw game data} -\usage{ -clean_drive_dat(play_df) -} -\arguments{ -\item{play_df}{(\emph{data.frame} required): Performs data cleansing on Play-by-Play DataFrame, as pulled from \code{cfbd_pbp_data()}} -} -\value{ -The original \code{play_df} with the following columns appended/redefined: -\describe{ -\item{lag_change_of_poss}{.} -\item{lag_punt}{.} -\item{lag_scoring_play}{.} -\item{lag_turnover_vec}{.} -\item{lag_downs_turnover}{.} -\item{lead_play_type}{.} -\item{lead_play_type2}{.} -\item{lead_play_type3}{.} -\item{drive_numbers}{.} -\item{number_of_drives}{.} -\item{pts_scored}{.} -\item{drive_result_detailed}{.} -\item{drive_result_detailed_flag}{.} -\item{drive_result2}{.} -\item{lag_new_drive_pts}{.} -\item{lag_drive_result_detailed}{.} -\item{lead_drive_result_detailed}{.} -\item{new_drive_pts}{.} -\item{drive_scoring}{.} -\item{drive_play}{.} -\item{drive_play_number}{.} -\item{drive_event}{.} -\item{drive_event_number}{.} -\item{new_id}{.} -\item{log_ydstogo}{.} -\item{down}{.} -\item{distance}{.} -\item{yards_to_goal}{.} -\item{yards_gained}{.} -\item{Goal_To_Go}{.} -} -} -\description{ -Create new Drive results and id data -Cleans Play-by-Play data pulled from the API's raw game data -} -\keyword{internal} diff --git a/man/clean_drive_info.Rd b/man/clean_drive_info.Rd deleted file mode 100644 index 66ee03a4..00000000 --- a/man/clean_drive_info.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/cfbd_pbp_data.R -\name{clean_drive_info} -\alias{clean_drive_info} -\title{Clean Drive Information -Cleans CFB (D-I) Drive-By-Drive Data to create \code{pts_drive} column} -\usage{ -clean_drive_info(drive_df) -} -\arguments{ -\item{drive_df}{(\emph{data.frame} required) Drive dataframe pulled from API via the \code{cfbd_drives()} function} -} -\value{ -The original \code{drive_df} with the following columns appended to it: -\describe{ -\item{drive_id}{Returned as \code{drive_id} from original variable \code{drive_id}} -\item{pts_drive}{End result of the drive} -\item{scoring}{Logical flag for if drive was a scoring drive updated} -} -} -\description{ -Clean Drive Information -Cleans CFB (D-I) Drive-By-Drive Data to create \code{pts_drive} column -} -\details{ -Cleans CFB (D-I) Drive-By-Drive Data to create \code{pts_drive} column. Requires the following columns be present: -\itemize{ -\item{drive_id}{Returned as \code{drive_id}} -\item{drive_result}{End result of the drive} -\item{scoring}{Logical flag for if drive was a scoring drive} -\item{game_id}{Unique game identifier} -} -} -\keyword{internal} diff --git a/man/clean_pbp_dat.Rd b/man/clean_pbp_dat.Rd deleted file mode 100644 index 6f92346e..00000000 --- a/man/clean_pbp_dat.Rd +++ /dev/null @@ -1,91 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helper_pbp_clean_pbp_dat.R -\name{clean_pbp_dat} -\alias{clean_pbp_dat} -\title{Clean Play-by-Play data -Cleans Play-by-Play data pulled from the API's raw game data} -\usage{ -clean_pbp_dat(play_df) -} -\arguments{ -\item{play_df}{(\emph{data.frame} required): Performs data cleansing on Play-by-Play DataFrame, as pulled from \code{cfbd_pbp_data()}} -} -\value{ -The original \code{play_df} with the following columns appended/redefined: -\describe{ -\item{scoring_play}{.} -\item{td_play}{.} -\item{touchdown}{.} -\item{safety}{.} -\item{fumble_vec}{.} -\item{kickoff_play}{.} -\item{kickoff_tb}{.} -\item{kickoff_onside}{.} -\item{kickoff_oob}{.} -\item{kickoff_fair_catch}{.} -\item{kickoff_downed}{.} -\item{kick_play}{.} -\item{kickoff_safety}{.} -\item{punt}{.} -\item{punt_play}{.} -\item{punt_tb}{.} -\item{punt_oob}{.} -\item{punt_fair_catch}{.} -\item{punt_downed}{.} -\item{rush}{.} -\item{pass}{.} -\item{sack_vec}{.} -\item{play_type}{.} -\item{td_check}{.} -\item{id_play}{.} -\item{sack}{.} -\item{int}{.} -\item{int_td}{.} -\item{completion}{.} -\item{pass_attempt}{.} -\item{target}{.} -\item{pass_td}{.} -\item{rush_td}{.} -\item{turnover_vec}{.} -\item{offense_score_play}{.} -\item{defense_score_play}{.} -\item{downs_turnover}{.} -\item{scoring_play}{.} -\item{fg_inds}{.} -\item{yds_fg}{.} -\item{yards_to_goal}{.} -\item{lag_play_type3}{.} -\item{lag_play_type2}{.} -\item{lag_play_type}{.} -\item{lead_play_type}{.} -\item{lead_play_type2}{.} -\item{lead_play_type3}{.} -} -} -\description{ -Clean Play-by-Play data -Cleans Play-by-Play data pulled from the API's raw game data -} -\details{ -Requires the following columns to be present -\describe{ -\item{game_id}{.} -\item{id_play}{.} -\item{offense_play}{.} -\item{defense_play}{.} -\item{home}{.} -\item{away}{.} -\item{play_type}{.} -\item{play_text}{.} -\item{kickoff_play}{.} -\item{down}{.} -\item{distance}{.} -\item{yards_gained}{.} -\item{yards_to_goal}{.} -\item{change_of_poss}{.} -\item{penalty_1st_conv}{.} -\item{off_timeouts_rem_before}{.} -\item{def_timeouts_rem_before}{.} -} -} -\keyword{internal} diff --git a/man/create_epa.Rd b/man/create_epa.Rd index d4ead53a..506daae3 100644 --- a/man/create_epa.Rd +++ b/man/create_epa.Rd @@ -2,31 +2,38 @@ % Please edit documentation in R/create_epa.R \name{create_epa} \alias{create_epa} -\title{Create EPA -Adds Expected Points calculations to Play-by-Play data.frame} +\alias{epa_fg_probs} +\title{Create EPA} \usage{ create_epa(play_df, ep_model, fg_model) + +epa_fg_probs(dat, current_probs, ep_model, fg_mod) } \arguments{ -\item{ep_model}{(\emph{model} default cfbfastR:::ep_model): Expected Points (EP) Model} +\item{ep_model}{(\strong{model}, default \code{cfbfastR}'s \code{ep_model}): FG Model to be used for prediction on field goal (FG) attempts in Play-by-Play data.frame} + +\item{fg_model}{(\emph{model} default \code{cfbfastR}'s \code{fg_model}): Field Goal (FG) Model} + +\item{current_probs}{(\strong{data.frame} required): Expected Points (EP) model raw probability outputs from initial prediction} + +\item{fg_mod}{(\strong{model}, default \code{cfbfastR}'s \code{fg_model}): FG Model to be used for prediction on field goal (FG) attempts in Play-by-Play data.frame} -\item{fg_model}{(\emph{model} default cfbfastR:::fg_model): Field Goal (FG) Model} +\item{clean_pbp_dat}{(\emph{data.frame} required): Clean PBP as input from \code{\link[=cfbd_pbp_data]{cfbd_pbp_data()}}} -\item{clean_pbp_dat}{(\emph{data.frame} required): Clean PBP as input from \code{\link[cfbfastR:cfbd_pbp_data]{cfbfastR::cfbd_pbp_data()}})} +\item{df}{(\strong{data.frame} required): Clean Play-By-Play data.frame as can be pulled from \code{\link[=clean_pbp_dat]{clean_pbp_dat()}}} } \description{ -Create EPA Adds Expected Points calculations to Play-by-Play data.frame } \details{ Code Description \describe{ -\item{1. \code{pred_df}}{Use select before play model variables -> Make predictions.} -\item{2. \code{epa_fg_probs}}{Update expected points predictions from before variables with FG make/miss probability weighted adjustment.} -\item{3. \code{pred_df_after}}{Use select after play model variables -> Make predictions .} -\item{4. \code{join_ep}}{Join \code{ep_before} calcs \code{pred_df} with ep_after calcs \code{pred_df_after} on c("game_id","drive_id","new_id").} -\item{5. \code{kickoffs}}{Calculate ep_before for kickoffs as if the pre-play assumption is a touchback.} -\item{6. \code{wpa_prep}}{Prep variables for WPA.} +\item{1. \code{pred_df}:}{Use select before play model variables -> Make predictions.} +\item{2. \code{epa_fg_probs}:}{Update expected points predictions from before variables with FG make/miss probability weighted adjustment.} +\item{3. \code{pred_df_after}:}{Use select after play model variables -> Make predictions.} +\item{4. \code{join_ep}:}{Join \code{ep_before} calcs \code{pred_df} with \code{ep_after} calcs \code{pred_df_after} on c("game_id","drive_id","new_id").} +\item{5. \code{kickoffs}:}{Calculate ep_before for kickoffs as if the pre-play assumption is a touchback.} +\item{6. \code{wpa_prep}:}{Prep variables for WPA.} } } \keyword{internal} diff --git a/man/create_wpa_naive.Rd b/man/create_wpa.Rd similarity index 89% rename from man/create_wpa_naive.Rd rename to man/create_wpa.Rd index 5670dcc0..a0bf687e 100644 --- a/man/create_wpa_naive.Rd +++ b/man/create_wpa.Rd @@ -1,11 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/create_wpa_naive.R -\name{create_wpa_naive} +\name{create_wpa} +\alias{create_wpa} \alias{create_wpa_naive} -\title{Add Win Probability Added (WPA) calculations to Play-by-Play DataFrame -This is only for D1 football} +\alias{wpa_calcs_naive} +\title{Add Win Probability Added (WPA) calculations to Play-by-Play DataFrame} \usage{ create_wpa_naive(df, wp_model) + +wpa_calcs_naive(df) } \arguments{ \item{df}{(\emph{data.frame} required): Clean Play-by-Play data.frame with Expected Points Added (EPA) calculations} @@ -37,7 +40,7 @@ The original \code{df} with the following columns appended to it: } } \description{ -Extracts raw game by game data. +This is only for D1 football } \details{ Requires the following columns to be present in the input data frame. diff --git a/man/epa_fg_probs.Rd b/man/epa_fg_probs.Rd deleted file mode 100644 index 3eceecb4..00000000 --- a/man/epa_fg_probs.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/create_epa.R -\name{epa_fg_probs} -\alias{epa_fg_probs} -\title{Performs Field Goal adjustments for Expected Points model calculations} -\usage{ -epa_fg_probs(dat, current_probs, ep_model, fg_mod) -} -\arguments{ -\item{current_probs}{(\emph{data.frame} required): Expected Points (EP) model raw probability outputs from initial prediction} - -\item{ep_model}{(\emph{model}, default \code{cfbfastR:::ep_model}): FG Model to be used for prediction on field goal (FG) attempts in Play-by-Play data.frame} - -\item{fg_mod}{(\emph{model}, default \code{cfbfastR:::fg_model}): FG Model to be used for prediction on field goal (FG) attempts in Play-by-Play data.frame} - -\item{df}{(\emph{data.frame} required): Clean Play-By-Play data.frame as can be pulled from \code{cfbd_pbp_dat()}} -} -\description{ -Extracts raw game by game data. -} -\keyword{internal} diff --git a/man/espn_metrics.Rd b/man/espn_metrics.Rd index 4615b6c6..5573bd64 100644 --- a/man/espn_metrics.Rd +++ b/man/espn_metrics.Rd @@ -12,16 +12,17 @@ espn_metrics_wp(game_id) } \arguments{ \item{game_id}{(\emph{Integer} required): Game ID filter for querying a single game\cr -Can be found using the \code{\link[cfbfastR:cfbd_game_info]{cfbfastR::cfbd_game_info()}} function} +Can be found using the \code{\link[=cfbd_game_info]{cfbd_game_info()}} function} } \value{ -espn_metrics_wp - A data frame with 5 variables: +\code{\link[=espn_metrics_wp]{espn_metrics_wp()}} - A data frame with 5 variables: \describe{ -\item{\code{espn_game_id}}{character.} -\item{\code{play_id}}{character.} -\item{\code{seconds_left}}{integer.} -\item{\code{home_win_percentage}}{double.} -\item{\code{away_win_percentage}}{double.} +\item{\code{game_id}: character.}{Referencing game ID (should be same as \code{game_id} from other functions).} +\item{\code{play_id}: character.}{Referencing play ID.} +\item{\code{seconds_left}: integer.}{Seconds left in the game.} +\item{\code{home_win_percentage}: double.}{The probability of the home team winning the game.} +\item{\code{away_win_percentage}: double.}{The probability of the away team winning the game (calculated as 1 - \code{home_win_percentage} - \code{tie_percentage}).} +\item{\code{tie_percentage}: double.}{The probability of the game ending the final period in a tie.} } } \description{ diff --git a/man/espn_ratings.Rd b/man/espn_ratings.Rd index 617ba195..df1c60f8 100644 --- a/man/espn_ratings.Rd +++ b/man/espn_ratings.Rd @@ -3,7 +3,7 @@ \name{espn_ratings} \alias{espn_ratings} \alias{espn_ratings_fpi} -\title{ESPN Ratings} +\title{ESPN FPI Ratings} \source{ \url{https://github.com/sabinanalytics/cfbfastR/blob/master/R/cfbd_ratings_fpi.R} } @@ -16,36 +16,34 @@ espn_ratings_fpi(year = 2019) \value{ A data frame with 20 variables: \describe{ -\item{\code{year}}{double.} -\item{\code{id}}{character.} -\item{\code{name}}{character.} -\item{\code{abbr}}{character.} -\item{\code{row_n}}{integer.} -\item{\code{fpi}}{character.} -\item{\code{fpi_rk}}{character.} -\item{\code{trend}}{character.} -\item{\code{proj_w}}{character.} -\item{\code{proj_l}}{character.} -\item{\code{win_out}}{double.} -\item{\code{win_6}}{double.} -\item{\code{win_div}}{double.} -\item{\code{playoff}}{double.} -\item{\code{nc_game}}{double.} -\item{\code{nc_win}}{double.} -\item{\code{win_conf}}{double.} -\item{\code{w}}{character.} -\item{\code{l}}{character.} -\item{\code{t}}{character.} +\item{\code{year}: double.}{Season of the Football Power Index (FPI) Rating.} +\item{\code{team_id}: character.}{Unique ESPN team ID - \code{team_id}.} +\item{\code{name}: character.}{Team Name.} +\item{\code{abbr}: character.}{Team abbreviation.} +\item{\code{fpi}: character.}{Football Power Index (FPI) Rating.} +\item{\code{fpi_rk}: character.}{Football Power Index (FPI) Rank.} +\item{\code{trend}: character.}{Football Power Index (FPI) ranking trend.} +\item{\code{proj_w}: character.}{Projected Win total for the season.} +\item{\code{proj_l}: character.}{Projected Loss total for the season.} +\item{\code{win_out}: double.}{Probability the team wins out.} +\item{\code{win_6}: double.}{Probability the team wins at least six games.} +\item{\code{win_div}: double.}{Probability the team wins at their division.} +\item{\code{playoff}: double.}{Probability the team reaches the playoff.} +\item{\code{nc_game}: double.}{Probability the team reaches the national championship game.} +\item{\code{nc_win}: double.}{Probability the team wins the national championship game.} +\item{\code{win_conf}: double.}{Probability the team wins their conference game.} +\item{\code{w}: character.}{Wins on the season.} +\item{\code{l}: character.}{Losses on the season.} +\item{\code{t}: character.}{Ties on the season.} } } \description{ -ESPN Ratings - Get FPI historical rating data (most recent of each year) +} +\details{ Adapted from sabinanalytic's fork of the cfbfastR repo } \examples{ - espn_ratings_fpi(year = 2018) } \keyword{FPI} diff --git a/man/helpers_pbp.Rd b/man/helpers_pbp.Rd new file mode 100644 index 00000000..3916005c --- /dev/null +++ b/man/helpers_pbp.Rd @@ -0,0 +1,397 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cfbd_pbp_data.R, +% R/helper_pbp_add_player_cols.R, R/helper_pbp_add_yardage.R, +% R/helper_pbp_clean_pbp_dat.R, R/helper_pbp_penalty_detection.R +\name{helpers_pbp} +\alias{helpers_pbp} +\alias{add_play_counts} +\alias{clean_drive_dat} +\alias{prep_epa_df_after} +\alias{clean_drive_info} +\alias{add_player_cols} +\alias{add_yardage} +\alias{clean_pbp_dat} +\alias{penalty_detection} +\title{Series of functions to help clean the play-by-play data for analysis} +\usage{ +add_play_counts(play_df) + +clean_drive_dat(play_df) + +prep_epa_df_after(dat) + +clean_drive_info(drive_df) + +add_player_cols(pbp) + +add_yardage(play_df) + +clean_pbp_dat(play_df) + +penalty_detection(raw_df) +} +\arguments{ +\item{play_df}{(\emph{data.frame} required): Performs data cleansing on Play-by-Play DataFrame, as pulled from \code{cfbd_pbp_data()}} + +\item{dat}{(\emph{Data.Frame} required) Clean Play-by-Play DataFrame pulled from \code{cfbd_pbp_dat()}} + +\item{drive_df}{(\emph{data.frame} required) Drive dataframe pulled from API via the \code{cfbd_drives()} function} + +\item{raw_df}{(\emph{data.frame} required): Performs data cleansing on Play-by-Play DataFrame, as pulled from \code{cfbd_pbp_data()}} +} +\value{ +The original \code{play_df} with the following columns appended/redefined: +\describe{ +\item{\code{game_play_number}.}{.} +\item{\code{half_clock.minutes}.}{.} +\item{\code{TimeSecsRem}.}{.} +\item{\code{Under_two}.}{.} +\item{\code{half}.}{.} +\item{\code{kickoff_play}.}{.} +\item{\code{pos_team}.}{.} +\item{\code{def_pos_team}.}{.} +\item{\code{receives_2H_kickoff}.}{.} +\item{\code{pos_score_diff}.}{.} +\item{\code{lag_pos_score_diff}.}{.} +\item{\code{lag_pos_team}.}{.} +\item{\code{lead_pos_team}.}{.} +\item{\code{lead_pos_team2}.}{.} +\item{\code{pos_score_pts}.}{.} +\item{\code{pos_score_diff_start}.}{.} +\item{\code{score_diff}.}{.} +\item{\code{lag_score_diff}.}{.} +\item{\code{lag_offense_play}.}{.} +\item{\code{lead_offense_play}.}{.} +\item{\code{lead_offense_play2}.}{.} +\item{\code{score_pts}.}{.} +\item{\code{score_diff_start}.}{.} +\item{\code{offense_receives_2H_kickoff}.}{.} +\item{\code{half_play_number}.}{.} +\item{\code{lag_off_timeouts}.}{.} +\item{\code{lag_def_timeouts}.}{.} +\item{\code{off_timeouts_rem_before}.}{.} +\item{\code{def_timeouts_rem_before}.}{.} +\item{\code{off_timeout_called}.}{.} +\item{\code{def_timeout_called}.}{.} +\item{\code{lead_TimeSecsRem}.}{.} +\item{\code{lead_TimeSecsRem2}.}{.} +\item{\code{lead_yards_to_goal}.}{.} +\item{\code{lead_yards_to_goal2}.}{.} +\item{\code{lead_down}.}{.} +\item{\code{lead_down2}.}{.} +\item{\code{lag_distance3}.}{.} +\item{\code{lag_distance2}.}{.} +\item{\code{lag_distance}.}{.} +\item{\code{lead_distance}.}{.} +\item{\code{lead_distance2}.}{.} +\item{\code{end_of_half}.}{.} +\item{\code{lag_play_type3}.}{.} +\item{\code{lag_play_type2}.}{.} +\item{\code{lag_play_type}.}{.} +\item{\code{lead_play_type}.}{.} +\item{\code{lead_play_type2}.}{.} +\item{\code{lead_play_type3}.}{.} +\item{\code{change_of_poss}.}{.} +\item{\code{change_of_pos_team}.}{.} +\item{\code{pos_team_timeouts}.}{.} +\item{\code{def_pos_team_timeouts}.}{.} +\item{\code{pos_team_timeouts_rem_before}.}{.} +\item{\code{def_pos_team_timeouts_rem_before}.}{.} +} + +The original \code{play_df} with the following columns appended/redefined: +\describe{ +\item{\code{lag_change_of_poss}.}{.} +\item{\code{lag_punt}.}{.} +\item{\code{lag_scoring_play}.}{.} +\item{\code{lag_turnover_vec}.}{.} +\item{\code{lag_downs_turnover}.}{.} +\item{\code{lead_play_type}.}{.} +\item{\code{lead_play_type2}.}{.} +\item{\code{lead_play_type3}.}{.} +\item{\code{drive_numbers}.}{.} +\item{\code{number_of_drives}.}{.} +\item{\code{pts_scored}.}{.} +\item{\code{drive_result_detailed}.}{.} +\item{\code{drive_result_detailed_flag}.}{.} +\item{\code{drive_result2}.}{.} +\item{\code{lag_new_drive_pts}.}{.} +\item{\code{lag_drive_result_detailed}.}{.} +\item{\code{lead_drive_result_detailed}.}{.} +\item{\code{new_drive_pts}.}{.} +\item{\code{drive_scoring}.}{.} +\item{\code{drive_play}.}{.} +\item{\code{drive_play_number}.}{.} +\item{\code{drive_event}.}{.} +\item{\code{drive_event_number}.}{.} +\item{\code{new_id}.}{.} +\item{\code{log_ydstogo}.}{.} +\item{\code{down}.}{.} +\item{\code{distance}.}{.} +\item{\code{yards_to_goal}.}{.} +\item{\code{yards_gained}.}{.} +\item{\code{Goal_To_Go}.}{.} +} + +\code{dat} with the following columns appended/modified: +\itemize{ +\item{\code{turnover_indicator}.}{.} +\item{\code{down}.}{.} +\item{\code{new_id}.}{.} +\item{\code{new_down}.}{.} +\item{\code{distance}.}{.} +\item{\code{yards_to_goal}.}{.} +\item{\code{yards_gained}.}{.} +\item{\code{turnover}.}{.} +\item{\code{drive_start_yards_to_goal}.}{.} +\item{\code{end_of_half}.}{.} +\item{\code{new_yardline}.}{.} +\item{\code{new_distance}.}{.} +\item{\code{new_log_ydstogo}.}{.} +\item{\code{new_Goal_To_Go}.}{.} +\item{\code{new_TimeSecsRem}.}{.} +\item{\code{new_Under_two}.}{.} +\item{\code{first_by_penalty}.}{.} +\item{\code{lag_first_by_penalty}.}{.} +\item{\code{lag_first_by_penalty2}.}{.} +\item{\code{first_by_yards}.}{.} +\item{\code{lag_first_by_yards}.}{.} +\item{\code{lag_first_by_yards2}.}{.} +\item{\code{row}.}{.} +\item{\code{new_series}.}{.} +\item{\code{firstD_by_kickoff}.}{.} +\item{\code{firstD_by_poss}.}{.} +\item{\code{firstD_by_yards}.}{.} +\item{\code{firstD_by_penalty}.}{.} +\item{\code{yds_punted}.}{.} +\item{\code{yds_punt_gained}.}{.} +\item{\code{missing_yard_flag}.}{.} +} + +The original \code{drive_df} with the following columns appended to it: +\describe{ +\item{\code{drive_id}: Returned as \code{drive_id} from original variable \code{drive_id}}{.} +\item{\code{pts_drive}: End result of the drive}{.} +\item{\code{scoring}: Logical flag for if drive was a scoring drive updated}{.} +} + +The original \code{pbp} with the following columns appended to it: +\describe{ +\item{\code{rusher_player_name}}{.} +\item{\code{receiver_player_name}}{.} +\item{\code{passer_player_name}}{.} +\item{\code{sack_player_name}}{.} +\item{\code{sack_player_name2}}{.} +\item{\code{pass_breakup_player_name}}{.} +\item{\code{interception_player_name}}{.} +\item{\code{fg_kicker_player_name}}{.} +\item{\code{fg_block_player_name}}{.} +\item{\code{fg_return_player_name}}{.} +\item{\code{kickoff_player_name}}{.} +\item{\code{kickoff_returner_player_name}}{.} +\item{\code{punter_player_name}}{.} +\item{\code{punt_block_player_name}}{.} +\item{\code{punt_returner_player_name}}{.} +\item{\code{punt_block_return_player_name}}{.} +\item{\code{fumble_player_name}}{.} +\item{\code{fumble_forced_player_name}}{.} +\item{\code{fumble_recovered_player_name}}{.} +} + +The original \code{play_df} with the following columns appended to it: +\describe{ +\item{\code{yds_rushed}}{.} +\item{\code{yds_receiving}}{.} +\item{\code{yds_int_return}}{.} +\item{\code{yds_kickoff}}{.} +\item{\code{yds_kickoff_return}}{.} +\item{\code{yds_punted}}{.} +\item{\code{yds_fumble_return}}{.} +\item{\code{yds_sacked}}{.} +\item{\code{yds_penalty}}{.} +} + +The original \code{play_df} with the following columns appended/redefined: +\describe{ +\item{scoring_play}{.} +\item{td_play}{.} +\item{touchdown}{.} +\item{safety}{.} +\item{fumble_vec}{.} +\item{kickoff_play}{.} +\item{kickoff_tb}{.} +\item{kickoff_onside}{.} +\item{kickoff_oob}{.} +\item{kickoff_fair_catch}{.} +\item{kickoff_downed}{.} +\item{kick_play}{.} +\item{kickoff_safety}{.} +\item{punt}{.} +\item{punt_play}{.} +\item{punt_tb}{.} +\item{punt_oob}{.} +\item{punt_fair_catch}{.} +\item{punt_downed}{.} +\item{rush}{.} +\item{pass}{.} +\item{sack_vec}{.} +\item{play_type}{.} +\item{td_check}{.} +\item{id_play}{.} +\item{sack}{.} +\item{int}{.} +\item{int_td}{.} +\item{completion}{.} +\item{pass_attempt}{.} +\item{target}{.} +\item{pass_td}{.} +\item{rush_td}{.} +\item{turnover_vec}{.} +\item{offense_score_play}{.} +\item{defense_score_play}{.} +\item{downs_turnover}{.} +\item{scoring_play}{.} +\item{fg_inds}{.} +\item{yds_fg}{.} +\item{yards_to_goal}{.} +\item{lag_play_type3}{.} +\item{lag_play_type2}{.} +\item{lag_play_type}{.} +\item{lead_play_type}{.} +\item{lead_play_type2}{.} +\item{lead_play_type3}{.} +} + +The original \code{raw_df} with the following columns appended/redefined: +\describe{ +\item{\code{penalty_flag}: TRUE/FALSE flag for penalty play types or penalty in play text plays.}{.} +\item{\code{penalty_declined}: TRUE/FALSE flag for 'declined' in penalty play types or penalty in play text plays.}{.} +\item{\code{penalty_no_play}: TRUE/FALSE flag for 'no play' in penalty play types or penalty in play text plays.}{.} +\item{\code{penalty_offset}: TRUE/FALSE flag for 'off-setting' in penalty play types or penalty in play text plays.}{.} +\item{\code{penalty_1st_conv}: TRUE/FALSE flag for 1st Down in penalty play types or penalty in play text plays.}{.} +\item{\code{penalty_text}: TRUE/FALSE flag for penalty in text but not a penalty play type.}{.} +\item{\code{orig_play_type}: Copy of original play_type label prior to any changes by the proceeding functions}{.} +\item{\code{down}: Defines kickoff downs and penalties on kickoffs and converts them from 5 (as from the API) to 1.}{.} +\item{\code{play_type}: Defines \code{play_type}, "Penalty (Kickoff)", penalties on kickoffs with a repeat kick.}{.} +\item{\code{half}: Defines the half variable (1, 2).}{.} +} +} +\description{ +\describe{ +\item{\code{add_play_counts()}: function}{Adds play counts to Play-by-Play data pulled from the API's raw game data.} +\item{\code{add_yardage()}: Add yardage extracted from play text}{.} +\item{\code{add_player_cols()}: function}{Add player columns extracted from play text.} +\item{\code{clean_drive_dat()}: function}{Create new Drive results and id data.} +\item{\code{clean_pbp_dat()}: function}{Clean Play-by-Play data.} +\item{\code{penalty_detection()}: function}{Adds penalty columns to Play-by-Play data pulled from the API.} +\item{\code{prep_epa_df_after()}: function}{Creates the post-play inputs for the Expected Points model to predict on for each game.} +\item{\code{clean_drive_info()}: function}{Cleans CFB (D-I) Drive-By-Drive Data to create \code{pts_drive} column.} +} + +Cleans Play-by-Play data pulled from the API's raw game data +} +\details{ +Requires the following columns to be present +\describe{ +\item{\code{game_id}}{.} +\item{\code{id_play}}{.} +\item{\code{clock.minutes}}{.} +\item{\code{clock.seconds}}{.} +\item{\code{half}}{.} +\item{\code{period}}{.} +\item{\code{offense_play}}{.} +\item{\code{defense_play}}{.} +\item{\code{home}}{.} +\item{\code{away}}{.} +\item{\code{offense_score}}{.} +\item{\code{defense_score}}{.} +\item{\code{offense_timeouts}}{.} +\item{\code{offense_timeouts}}{.} +\item{\code{play_text}}{.} +\item{\code{play_type}}{.} +} + +Prep for EPA calculations at the end of the play. Requires the following columns be present: +\itemize{ +\item{\code{game_id}.}{.} +\item{\code{id_play}.}{.} +\item{\code{drive_id}.}{.} +\item{\code{down}.}{.} +\item{\code{distance}.}{.} +\item{\code{period}.}{.} +\item{\code{yards_to_goal}.}{.} +\item{\code{play_type}.}{.} +} + +Cleans CFB (D-I) Drive-By-Drive Data to create \code{pts_drive} column. Requires the following columns be present: +\itemize{ +\item{\code{drive_id}: Returned as \code{drive_id}}{.} +\item{\code{drive_result}: End result of the drive}{.} +\item{\code{scoring}: Logical flag for if drive was a scoring drive}{.} +\item{\code{game_id}: Unique game identifier}{.} +} + +Cleans CFB (D-I) player Data to create player name columns. Requires the following columns be present: +\itemize{ +\item{\code{rush}}{.} +\item{\code{pass}}{.} +\item{\code{play_text}}{.} +\item{\code{play_type}}{.} +\item{\code{sack}}{.} +\item{\code{fumble_vec}}{.} +} + +Cleans CFB (D-I) Drive-By-Drive Data to create yardage column. Requires the following columns be present: +\describe{ +\item{\code{play_text}}{.} +\item{\code{play_type}}{.} +\item{\code{rush}}{.} +\item{\code{pass}}{.} +\item{\code{int}}{.} +\item{\code{int_td}}{.} +\item{\code{kickoff_play}}{.} +\item{\code{kickoff_tb}}{.} +\item{\code{kickoff_downed}}{.} +\item{\code{kickoff_fair_catch}}{.} +\item{\code{fumble_vec}}{.} +\item{\code{sack}}{.} +\item{\code{punt}}{.} +\item{\code{punt_tb}}{.} +\item{\code{punt_downed}}{.} +\item{\code{punt_fair_catch}}{.} +\item{\code{punt_oob}}{.} +\item{\code{punt_blocked}}{.} +\item{\code{penalty_detail}}{.} +} + +Requires the following columns to be present +\describe{ +\item{game_id}{.} +\item{id_play}{.} +\item{offense_play}{.} +\item{defense_play}{.} +\item{home}{.} +\item{away}{.} +\item{play_type}{.} +\item{play_text}{.} +\item{kickoff_play}{.} +\item{down}{.} +\item{distance}{.} +\item{yards_gained}{.} +\item{yards_to_goal}{.} +\item{change_of_poss}{.} +\item{penalty_1st_conv}{.} +\item{off_timeouts_rem_before}{.} +\item{def_timeouts_rem_before}{.} +} + +Runs penalty detection on the play text and play types. Requires the following columns be present: +\itemize{ +\item{\code{game_id}}{Referencing game id.} +\item{\code{period}}{Game period (quarter).} +\item{\code{down}}{Down of the play.} +\item{\code{play_type}}{Categorical play type.} +\item{\code{play_text}}{A description of the play.} +} +} +\keyword{internal} diff --git a/man/load_cfb_pbp.Rd b/man/load_cfb_pbp.Rd index bf8d5752..0ba9d01a 100644 --- a/man/load_cfb_pbp.Rd +++ b/man/load_cfb_pbp.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R +% Please edit documentation in R/cfb_pbp.R \name{load_cfb_pbp} \alias{load_cfb_pbp} \title{Load cfbfastR play-by-play} diff --git a/man/penalty_detection.Rd b/man/penalty_detection.Rd deleted file mode 100644 index a8bd7e82..00000000 --- a/man/penalty_detection.Rd +++ /dev/null @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helper_pbp_penalty_detection.R -\name{penalty_detection} -\alias{penalty_detection} -\title{Penalty Detection -Adds penalty columns to Play-by-Play data pulled from the API} -\usage{ -penalty_detection(raw_df) -} -\arguments{ -\item{raw_df}{(\emph{data.frame} required): Performs data cleansing on Play-by-Play DataFrame, as pulled from \code{cfbd_pbp_data()}} -} -\value{ -The original \code{raw_df} with the following columns appended/redefined: -\describe{ -\item{penalty_flag}{TRUE/FALSE flag for penalty play types or penalty in play text plays.} -\item{penalty_declined}{TRUE/FALSE flag for 'declined' in penalty play types or penalty in play text plays.} -\item{penalty_no_play}{TRUE/FALSE flag for 'no play' in penalty play types or penalty in play text plays.} -\item{penalty_offset}{TRUE/FALSE flag for 'off-setting' in penalty play types or penalty in play text plays.} -\item{penalty_1st_conv}{TRUE/FALSE flag for 1st Down in penalty play types or penalty in play text plays.} -\item{penalty_text}{TRUE/FALSE flag for penalty in text but not a penalty play type.} -\item{orig_play_type}{Copy of original play_type label prior to any changes by the proceeding functions} -\item{down}{Defines kickoff downs and penalties on kickoffs and converts them from 5 (as from the API) to 1.} -\item{play_type}{Defines \code{play_type}, "Penalty (Kickoff)", penalties on kickoffs with a repeat kick.} -\item{half}{Defines the half variable (1, 2).} -} -} -\description{ -Penalty Detection -Adds penalty columns to Play-by-Play data pulled from the API -} -\details{ -Runs penalty detection on the play text and play types. Requires the following columns be present: -\itemize{ -\item{game_id} -\item{period} -\item{down} -\item{play_type} -\item{play_text} -} -} -\keyword{internal} diff --git a/man/prep_epa_df_after.Rd b/man/prep_epa_df_after.Rd deleted file mode 100644 index 58373cc6..00000000 --- a/man/prep_epa_df_after.Rd +++ /dev/null @@ -1,64 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/cfbd_pbp_data.R -\name{prep_epa_df_after} -\alias{prep_epa_df_after} -\title{Creates the post-play inputs for the Expected Points model to predict on for each game} -\usage{ -prep_epa_df_after(dat) -} -\arguments{ -\item{dat}{(\emph{Data.Frame} required) Clean Play-by-Play DataFrame pulled from \code{cfbd_pbp_dat()}} -} -\value{ -\code{dat} with the following columns appended/modified: -\itemize{ -\item{turnover_indicator}{.} -\item{down}{.} -\item{new_id}{.} -\item{new_down}{.} -\item{distance}{.} -\item{yards_to_goal}{.} -\item{yards_gained}{.} -\item{turnover}{.} -\item{drive_start_yards_to_goal}{.} -\item{end_of_half}{.} -\item{new_yardline}{.} -\item{new_distance}{.} -\item{new_log_ydstogo}{.} -\item{new_Goal_To_Go}{.} -\item{new_TimeSecsRem}{.} -\item{new_Under_two}{.} -\item{first_by_penalty}{.} -\item{lag_first_by_penalty}{.} -\item{lag_first_by_penalty2}{.} -\item{first_by_yards}{.} -\item{lag_first_by_yards}{.} -\item{lag_first_by_yards2}{.} -\item{row}{.} -\item{new_series}{.} -\item{firstD_by_kickoff}{.} -\item{firstD_by_poss}{.} -\item{firstD_by_yards}{.} -\item{firstD_by_penalty}{.} -\item{yds_punted}{.} -\item{yds_punt_gained}{.} -\item{missing_yard_flag}{.} -} -} -\description{ -Creates the post-play inputs for the Expected Points model to predict on for each game -} -\details{ -Prep for EPA calculations at the end of the play. Requires the following columns be present: -\itemize{ -\item{game_id} -\item{id_play} -\item{drive_id} -\item{down} -\item{distance} -\item{period} -\item{yards_to_goal} -\item{play_type} -} -} -\keyword{internal} diff --git a/man/update_cfb_db.Rd b/man/update_cfb_db.Rd index 44c3b62c..425994c2 100644 --- a/man/update_cfb_db.Rd +++ b/man/update_cfb_db.Rd @@ -1,10 +1,12 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helper_database_functions.R +% Please edit documentation in R/cfb_pbp.R \name{update_cfb_db} \alias{update_cfb_db} -\title{Update or Create a cfbfastR Play-by-Play Database -\code{update_cfb_db} updates or creates a database with \code{cfbfastR} -play by play data of all completed games since 2014.} +\alias{cfb_db} +\alias{cfb} +\alias{database} +\alias{cfb_pbp_db} +\title{Update or Create a cfbfastR Play-by-Play Database} \usage{ update_cfb_db( dbdir = ".", @@ -28,8 +30,7 @@ of or the complete play by play data table within the database (please see detai \code{\link[DBI:dbConnect]{DBI::dbConnect()}} (please see details for further information)} } \description{ -Update or Create a cfbfastR Play-by-Play Database -\code{update_cfb_db} updates or creates a database with \code{cfbfastR} +\code{update_cfb_db()} updates or creates a database with \code{cfbfastR} play by play data of all completed games since 2014. } \details{ diff --git a/man/wpa_calcs_naive.Rd b/man/wpa_calcs_naive.Rd deleted file mode 100644 index 32a0ef52..00000000 --- a/man/wpa_calcs_naive.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/create_wpa_naive.R -\name{wpa_calcs_naive} -\alias{wpa_calcs_naive} -\title{WPA Calcs} -\usage{ -wpa_calcs_naive(df) -} -\arguments{ -\item{df}{(\emph{data.frame} required): Clean Play-by-Play data.frame with Expected Points Added (EPA) calculations} -} -\description{ -Extracts raw game by game data. -} -\keyword{internal} diff --git a/pkgdown/extra.css b/pkgdown/extra.css index 0b214b7d..ba5a3506 100644 --- a/pkgdown/extra.css +++ b/pkgdown/extra.css @@ -45,27 +45,27 @@ pre, code { #tocnav ul ul { font-family: "Fira Mono"; margin-left: 5px; - font-size: 16px; + font-size: 12px; } .dropdown-menu { - box-shadow: 0 6px 12px rgba(0, 0, 0, 0.18); + box-shadow: 0 6px 12px rgba(5, 5, 5, 0.18); background-color: #222222; } #navbar ul ul{ font-family: "Fira Mono"; - letter-spacing: 0.1px; - line-height: 1.2rem; + letter-spacing: 0.05px; + line-height: 1.05rem; color: #fff; font-weight: 400; - font-size: 13px; + font-size: 12px; } .nav li a { font-family: "Fira Mono"; - letter-spacing: 0.1px; - line-height: 1.2rem; + letter-spacing: 0.05px; + line-height: 1.05rem; color: #fff; font-weight: 400; - font-size: 13px; + font-size: 12px; } .pkgdown { display: none; @@ -101,5 +101,5 @@ pre, code { font-family: "Bungee"; font-size: 16px; color: #F2EC84; - animation: glow 2.5s ease-in-out infinite alternate; + animation: glow 3s ease-in-out infinite alternate; } diff --git a/tests/testthat/test-cfbd_metrics_ppa_players_season.R b/tests/testthat/test-cfbd_metrics_ppa_players_season.R index 92e26ae7..d28d4ad9 100644 --- a/tests/testthat/test-cfbd_metrics_ppa_players_season.R +++ b/tests/testthat/test-cfbd_metrics_ppa_players_season.R @@ -1,23 +1,23 @@ -context("CFB Metrics PPA Players Season") - - -cols <- c( - "season", "id", "name", "position", "team", "conference", - "countable_plays", "avg_PPA_all", "avg_PPA_pass", - "avg_PPA_rush", "avg_PPA_first_down", "avg_PPA_second_down", - "avg_PPA_third_down", "avg_PPA_standard_downs", "avg_PPA_passing_downs", - "total_PPA_all", "total_PPA_pass", "total_PPA_rush", "total_PPA_first_down", - "total_PPA_second_down", "total_PPA_third_down", - "total_PPA_standard_downs", "total_PPA_passing_downs" -) - -test_that("CFB Metrics PPA Players Season", { - skip_on_cran() - x <- cfbd_metrics_ppa_players_season(year = 2019, team = "TCU") - - y <- cfbd_metrics_ppa_players_season(year = 2019, team = "Alabama") - expect_equal(colnames(x), cols) - expect_equal(colnames(y), cols) - expect_s3_class(x, "data.frame") - expect_s3_class(y, "data.frame") -}) +context("CFB Metrics PPA Players Season") + + +cols <- c( + "season", "athlete_id", "name", "position", "team", "conference", + "countable_plays", "avg_PPA_all", "avg_PPA_pass", + "avg_PPA_rush", "avg_PPA_first_down", "avg_PPA_second_down", + "avg_PPA_third_down", "avg_PPA_standard_downs", "avg_PPA_passing_downs", + "total_PPA_all", "total_PPA_pass", "total_PPA_rush", "total_PPA_first_down", + "total_PPA_second_down", "total_PPA_third_down", + "total_PPA_standard_downs", "total_PPA_passing_downs" +) + +test_that("CFB Metrics PPA Players Season", { + skip_on_cran() + x <- cfbd_metrics_ppa_players_season(year = 2019, team = "TCU") + + y <- cfbd_metrics_ppa_players_season(year = 2019, team = "Alabama") + expect_equal(colnames(x), cols) + expect_equal(colnames(y), cols) + expect_s3_class(x, "data.frame") + expect_s3_class(y, "data.frame") +}) diff --git a/tests/testthat/test-espn_metrics_wp.R b/tests/testthat/test-espn_metrics_wp.R index 71e4ec9d..1cb41d83 100644 --- a/tests/testthat/test-espn_metrics_wp.R +++ b/tests/testthat/test-espn_metrics_wp.R @@ -2,8 +2,8 @@ context("CFB Metrics ESPN Win Probability") cols <- c( - "espn_game_id", "play_id", "seconds_left", - "home_win_percentage", "away_win_percentage" + "game_id", "play_id", "seconds_left", + "home_win_percentage", "away_win_percentage", "tie_percentage" ) test_that("CFB Metrics ESPN Win Probability", { diff --git a/tests/testthat/test-espn_ratings_fpi.R b/tests/testthat/test-espn_ratings_fpi.R index 5751d9b6..1545c599 100644 --- a/tests/testthat/test-espn_ratings_fpi.R +++ b/tests/testthat/test-espn_ratings_fpi.R @@ -1,7 +1,7 @@ context("ESPN FPI Ratings") cols <- c( - "year", "id", "name", "abbr", "row_n", + "year", "team_id", "name", "abbr", "fpi", "fpi_rk", "trend", "proj_w", "proj_l", "win_out", "win_6", "win_div", "playoff", "nc_game", "nc_win", "win_conf", "w", "l", "t" diff --git a/vignettes/animated-wp-plotting.Rmd b/vignettes/animated-wp-plotting.Rmd index 4f9d1cac..3e185162 100644 --- a/vignettes/animated-wp-plotting.Rmd +++ b/vignettes/animated-wp-plotting.Rmd @@ -1,15 +1,20 @@ --- title: "Making Animated Win Probability Charts with cfbfastR" -author: "Jared Lee | @JaredDLee" +description: "Step-by-step walk-through of the process of adapting Lee Sharpe's win probability charts to college football using data from CollegeFootballData.com collected using the cfbfastR package for R." +author: "Jared Lee
@JaredDLee @Kazink36" +opengraph: + image: + src: "https://github.com/saiemgilani/cfbfastR-data/blob/master/themes/social_card_cfbfastR_final_quote.png?raw=true" + twitter: + creator: "@JaredDLee" + card: summary + site: "@cfbfastR" output: html_document --- ```{r setup, include=FALSE} old <- options(rmarkdown.html_vignette.check_title = FALSE) ``` -@JaredDLee -@Kazink36 - Have you ever wanted to make an [animated win probability chart](https://kazink36.github.io/images/animated_wp_ex_wide.gif) for college football like [Lee Sharpe](https://twitter.com/LeeSharpeNFL) makes for [the NFL](https://twitter.com/LeeSharpeNFL/status/1300526539344289792)? This document will walk you step-by-step through the process of adapting [Sharpe's code](https://github.com/leesharpe/nfldata/blob/master/code/wpchart.R) to college football using data from [CollegeFootballData.com](collegefootballdata.com) collected using the ```cfbfastR``` package for R. @@ -24,7 +29,7 @@ if (!requireNamespace('pacman', quietly = TRUE)){ install.packages('pacman') } pacman::p_load(tidyverse, animation, glue, zoo, ggimage) -pacman::p_load_gh("saiemgilani/cfbfastR") +pacman::p_load_current_gh("saiemgilani/cfbfastR") ``` ## cfbfastR @@ -73,7 +78,7 @@ game <- game %>% rename(home_score = home_points, away_score = away_points) ``` -To build the labels, we're going to use a custom function to pull the player names out of the play text. [Saiem Gilani](https://twitter.com/SaiemGilani) wrote the bulk of the regular expressions here to get the names. EDIT: The improved version of this is now included in the ```cfbd_pbp_data()``` function by default as of version 1.0.3. +To build the labels, we're going to use a custom function to pull the player names out of the play text. [Saiem Gilani](https://twitter.com/SaiemGilani) wrote the bulk of the regular expressions here to get the names. EDIT: The improved version of this is now included in the ```cfbd_pbp_data()``` function by default. Now we are ready to transform our play-by-play data frame to match what we need to work with Lee Sharpe's animation code. First, we will rename several columns that are similar between ```cfbfastR``` and ```nflfastR``` to match ```nflfastR```'s column names. Then we need to create a few new columns that ```cfbfastR``` doesn't have. `game_seconds_remaining` is really just renaming `TimeSecsRem` but correcting for the half. `result` grabs from the game information and is the difference in the home and away score. We create the `time` column to use as the clock on the right side of the animation. diff --git a/vignettes/cfbd_betting.Rmd b/vignettes/cfbd_betting.Rmd new file mode 100644 index 00000000..ae1b47e8 --- /dev/null +++ b/vignettes/cfbd_betting.Rmd @@ -0,0 +1,36 @@ +--- +title: "CFB Data Betting Lines Examples" +description: "Get betting lines information for games using cfbd_betting_lines()" +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: "https://github.com/saiemgilani/cfbfastR-data/blob/master/themes/social_card_cfbfastR_final_quote.png?raw=true" + twitter: + creator: "@saiemgilani" + card: summary + site: "@cfbfastR" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +### **Load and Install Packages** + +```{r} +if (!requireNamespace('pacman', quietly = TRUE)){ + install.packages('pacman') +} +pacman::p_load(dplyr,tidyr, gt) +pacman::p_load_current_gh("saiemgilani/cfbfastR") +``` + +### **Get Betting information from games** + +```{r} +cfbd_betting_lines(year = 2018, week = 12, team = "Florida State") + +# 7 OTs LSU at TAMU +cfbd_betting_lines(year = 2018, week = 13, team = "Texas A&M", conference = "SEC") +``` diff --git a/vignettes/cfbd_games.Rmd b/vignettes/cfbd_games.Rmd new file mode 100644 index 00000000..fde7ac53 --- /dev/null +++ b/vignettes/cfbd_games.Rmd @@ -0,0 +1,93 @@ +--- +title: "CFB Data Games Examples" +description: "Provides access to game-level team (cfbd_game_team_stats()) and player (cfbd_game_player_stats()) standard box scores, as well as team-level advanced box scores (cfbd_game_box_advanced()). Also useful for looking up game information (cfbd_game_info()), broadcast details (cfbd_game_media()), and team records/results information (cfbd_game_records())." +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: "https://github.com/saiemgilani/cfbfastR-data/blob/master/themes/social_card_cfbfastR_final_quote.png?raw=true" + twitter: + creator: "@saiemgilani" + card: summary + site: "@cfbfastR" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +### **Load and Install Packages** + +```{r} +if (!requireNamespace('pacman', quietly = TRUE)){ + install.packages('pacman') +} +pacman::p_load(dplyr,tidyr, gt) +pacman::p_load_current_gh("saiemgilani/cfbfastR") +``` + +### **Get game information** + +```{r, load_cfbd_games_ex, eval = FALSE} + +df_2018_wk_1 <- cfbfastR::cfbd_game_info(year=2018, week = 1) + +df_2018_wk_7_ind <- cfbfastR::cfbd_game_info(year=2018, week = 7, conference = "Ind") + +line_scores <- cfbfastR::cfbd_game_info(year=2018, week = 13, team = "Texas A&M", quarter_scores = TRUE) + +``` + +### **Get calendar weeks and dates** + +```{r, cfbd_calendar_ex, eval = FALSE} + +cfbfastR::cfbd_calendar(2019) + +``` + +### **Find game broadcast and media information** + +```{r, cfbd_game_media_ex, eval = FALSE} + +cfbfastR::cfbd_game_media(2019, week = 4, conference = "ACC") + +``` + +### **Get CFBD Advanced Game Box Scores (by `game_id`)** + +```{r, cfbd_game_box_adv_ex, eval = FALSE} + +cfbfastR::cfbd_game_box_advanced(game_id = 401114233) + +``` + +### **Get CFBD Game Team Box Scores** + +```{r, game_team_stats_ex} + +cfbfastR::cfbd_game_team_stats(2019, team = "LSU") + +cfbfastR::cfbd_game_team_stats(2013, team = "Florida State") + +``` + +### **Get CFBD Game Player Box Scores** + +```{r, game_player_stats_ex, eval = FALSE} + +cfbfastR::cfbd_game_player_stats(2018, week = 15, conference = "Ind") + +cfbfastR::cfbd_game_player_stats(2013, week = 1, team = "Florida State", category = "passing") + +``` + +### **Get CFBD Team Game Records** + +```{r, game_records_ex, eval = FALSE} + +cfbfastR::cfbd_game_records(2018, team = "Notre Dame") + +cfbfastR::cfbd_game_records(2013, team = "Florida State") + +``` diff --git a/vignettes/cfbd_plays.Rmd b/vignettes/cfbd_plays.Rmd new file mode 100644 index 00000000..a93a8534 --- /dev/null +++ b/vignettes/cfbd_plays.Rmd @@ -0,0 +1,64 @@ +--- +title: "CFB Data Plays Examples" +description: "Using the CFB Data Plays Endpoint to pull down the 2020 season by week using cfbd_plays()" +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: "https://github.com/saiemgilani/cfbfastR-data/blob/master/themes/social_card_cfbfastR_final_quote.png?raw=true" + twitter: + creator: "@saiemgilani" + card: summary + site: "@cfbfastR" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +### **Load and Install Packages** + +```{r cfbd_plays, eval=FALSE} +if (!requireNamespace('pacman', quietly = TRUE)){ + install.packages('pacman') +} +pacman::p_load(dplyr,tidyr) +pacman::p_load_current_gh("saiemgilani/cfbfastR") +``` + +### **Pull first 3 weeks of 2020 season using `cfbd_plays()`** + +```{r cfbd_plays_purrr, eval = FALSE} +year_vector <- 2020 +week_vector <- 1:3 +weekly_year_df <- expand.grid(year = year_vector, week = week_vector) + +tictoc::tic() +year_split <- split(weekly_year_df, weekly_year_df$year) +for (i in 1:length(year_split)) { + i <- 1 + future::plan("multisession") + progressr::with_progress({ + year_split[[i]] <- year_split[[i]] %>% + dplyr::mutate( + pbp = purrr::map2( + .x = year, + .y = week, + cfbd_plays, + season_type = "both" + ) + ) + + Sys.sleep(1) + }) +} + +tictoc::toc() + +year_split <- lapply(year_split, function(x) { + x %>% tidyr::unnest(pbp, names_repair = "minimal") +}) + +all_years <- dplyr::bind_rows(year_split) +glimpse(all_years) +``` diff --git a/vignettes/cfbd_recruiting.Rmd b/vignettes/cfbd_recruiting.Rmd new file mode 100644 index 00000000..7909d161 --- /dev/null +++ b/vignettes/cfbd_recruiting.Rmd @@ -0,0 +1,62 @@ +--- +title: "CFB Data Recruiting Examples" +description: "Accessing 247Sports composite recruiting data through the CFBD API using cfbd_recruiting_player() for Player Rankings, cfbd_recruiting_team() for Team Rankings and cfbd_recruiting_position() for Position Group metrics" +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: "https://github.com/saiemgilani/cfbfastR-data/blob/master/themes/social_card_cfbfastR_final_quote.png?raw=true" + twitter: + creator: "@saiemgilani" + card: summary + site: "@cfbfastR" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +### **Load and Install Packages** + +```{r} +if (!requireNamespace('pacman', quietly = TRUE)){ + install.packages('pacman') +} +pacman::p_load(dplyr,tidyr, gt) +pacman::p_load_current_gh("saiemgilani/cfbfastR") +``` + +### **CFBD Recruiting Player** + +Gets CFB recruiting information for a single year with filters available for team, recruit type, state and position. + +```{r recruiting_player_ex} +cfbd_recruiting_player(2018, team = "Texas") + +cfbd_recruiting_player(2016, recruit_type = "JUCO") + +cfbd_recruiting_player(2020, recruit_type = "HighSchool", position = "OT", state = "FL") +``` + +### **CFB Recruiting Information Position Groups.** + +```{r recruiting_position_ex} +cfbd_recruiting_position(2018, team = "Texas") + +cfbd_recruiting_position(2016, 2020, team = "Virginia") + +cfbd_recruiting_position(2015, 2020, conference = "SEC") +``` + +### **CFB Recruiting Information Team Rankings.** + +```{r recruiting_team_ex} +cfbd_recruiting_team(2018, team = "Texas") + +cfbd_recruiting_team(2016, team = "Virginia") + +cfbd_recruiting_team(2016, team = "Texas A&M") + +cfbd_recruiting_team(2011) +``` + diff --git a/vignettes/cfbd_stats.Rmd b/vignettes/cfbd_stats.Rmd new file mode 100644 index 00000000..06b6861b --- /dev/null +++ b/vignettes/cfbd_stats.Rmd @@ -0,0 +1,138 @@ +--- +title: "CFB Data Stats Examples" +description: "Settling 2019 LSU and 2013 Florida State offense debates using Team and Player Stats from the CFBD API" +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: "https://github.com/saiemgilani/cfbfastR-data/blob/master/themes/social_card_cfbfastR_final_quote.png?raw=true" + twitter: + creator: "@saiemgilani" + card: summary + site: "@cfbfastR" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +### **Load and Install Packages** + +```{r} +if (!requireNamespace('pacman', quietly = TRUE)){ + install.packages('pacman') +} +pacman::p_load(dplyr,tidyr, gt) +pacman::p_load_current_gh("saiemgilani/cfbfastR") +``` + +## Settling **2019 LSU** and **2013 Florida State** offense debates + +### **Get Season Statistics by Team** + +```{r team_season_stats} +team_season_stats <- dplyr::bind_rows( + cfbd_stats_season_team(2019, team = "LSU"), + cfbd_stats_season_team(2013, team = "Florida State") +) +logos <- read.csv("https://raw.githubusercontent.com/saiemgilani/cfbfastR-data/master/themes/logos.csv") +logos<- logos %>% dplyr::select(-.data$conference) +df_team_season <- team_season_stats %>% + dplyr::left_join(logos, by=c("team"="school")) +``` + +```{r team_season_long} +df_team_season_long <- as.data.frame(t(as.matrix(df_team_season))) +colnames(df_team_season_long) <- df_team_season$team +``` + +### **Get Season Advanced Statistics by Team** + +```{r team_season_adv} +df_team_season_adv <- dplyr::bind_rows( + cfbd_stats_season_advanced(2019, team = "LSU"), + cfbd_stats_season_advanced(2013, team = "Florida State") +) +df_team_season_adv <- df_team_season_adv %>% + dplyr::left_join(logos, by=c("team"="school")) + +``` + +### **Get Game Advanced Stats** + +```{r team_game_adv} +df_team_game_adv <- dplyr::bind_rows( + cfbd_stats_game_advanced(2019, team = "LSU"), + cfbd_stats_game_advanced(2013, team = "Florida State") +) +df_team_game_adv <- df_team_game_adv %>% + dplyr::left_join(logos, by=c("team"="school")) +``` + +### **Get Season Statistics by Player** + +```{r passing_stats_table_ex} +source("https://raw.githubusercontent.com/saiemgilani/cfbfastR-data/master/themes/gt_theme_code_SG.R") +passing_df <- dplyr::bind_rows( + cfbd_stats_season_player(2019, team = "LSU", category = "passing"), + cfbd_stats_season_player(2013, team = "Florida State", category = "passing")) %>% + dplyr::left_join(logos, by=c("team"="school")) %>% + dplyr::group_by(team) %>% + dplyr::select(logo, + player, + passing_completions, + passing_att, + passing_yds, + passing_td, + passing_int, + passing_ypa) %>% + arrange( desc(passing_yds), team) +passing_df %>% gt() %>% + tab_header(title = "Passing Summary") %>% + cols_label(logo="", + player = "Player", + passing_completions = "C", + passing_att = "Att", + passing_yds = "Yds", + passing_td = "TDs", + passing_int = "INTs", + passing_ypa = "YPA") %>% + data_color( + columns = vars(passing_yds), + colors = scales::col_numeric( + palette = "RdBu", + domain = c(-6000,6000) + ) + ) %>% + data_color( + columns = vars(passing_td), + colors = scales::col_numeric( + palette = "RdBu", + domain = c(-60,60) + ) + ) %>% + data_color( + columns = vars(passing_td), + colors = scales::col_numeric( + palette = "RdBu", + domain = c(-60,60) + ) + ) %>% + text_transform( + locations = cells_body(vars(logo)), + fn = function(logo){ + web_image(url= logo) + }) %>% + tab_source_note(source_note = md("**Table:** @SaiemGilani | **Data:** @CFB_Data with @cfbfastR v1.1.0")) %>% + gt_theme_538(table.width = px(550)) + +``` + +### **College Football Mapping for Stats Categories** + +```{r} + +cfbd_stats_categories() + +``` + diff --git a/vignettes/cfbd_teams.Rmd b/vignettes/cfbd_teams.Rmd new file mode 100644 index 00000000..5263d758 --- /dev/null +++ b/vignettes/cfbd_teams.Rmd @@ -0,0 +1,76 @@ +--- +title: "CFB Data Teams Examples" +description: "Get team rosters (cfbd_team_rosters()), talent (cfbd_team_talent()) and team matchup history (cfbd_team_matchup_history()) and records (cfbd_team_matchup_records()) from the CFBD API" +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: "https://github.com/saiemgilani/cfbfastR-data/blob/master/themes/social_card_cfbfastR_final_quote.png?raw=true" + twitter: + creator: "@saiemgilani" + card: summary + site: "@cfbfastR" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +### **Load and Install Packages** + +```{r} +if (!requireNamespace('pacman', quietly = TRUE)){ + install.packages('pacman') +} +pacman::p_load(dplyr,tidyr, gt) +pacman::p_load_current_gh("saiemgilani/cfbfastR") +``` + +### **Get Team Info** + +```{r team_info_ex} +cfbd_team_info(conference = "SEC") + +cfbd_team_info(conference = "Ind") + +cfbd_team_info(year = 2019) +``` + +### **Get Team Matchup History (Total Record)** + +```{r team_matchup_records_ex} + +cfbd_team_matchup_records("Texas", "Oklahoma") + +cfbd_team_matchup_records("Texas A&M", "TCU", min_year = 1975) + +``` + +### **Get Team Matchup History** + +```{r team_matchup_ex} +cfbd_team_matchup("Texas", "Oklahoma") + +cfbd_team_matchup("Texas A&M", "TCU") + +cfbd_team_matchup("Texas A&M", "TCU", min_year = 1975) + +cfbd_team_matchup("Florida State", "Florida", min_year = 1975) +``` + +### **Get Team Rosters** + +```{r team_roster_ex} + +cfbd_team_roster(year = 2013, team = "Florida State") + +``` + +### **Get Team Talent** + +```{r team_talent_ex} +cfbd_team_talent() + +cfbd_team_talent(year = 2018) + +``` diff --git a/vignettes/college-football-expected-points-model-fundamentals-part-i.Rmd b/vignettes/college-football-expected-points-model-fundamentals-part-i.Rmd index ef8db682..851429a7 100644 --- a/vignettes/college-football-expected-points-model-fundamentals-part-i.Rmd +++ b/vignettes/college-football-expected-points-model-fundamentals-part-i.Rmd @@ -1,6 +1,14 @@ --- title: "College Football Expected Points Model Fundamentals - Part I" -author: "Saiem Gilani" +description: "Expected points model definition - a model explainer" +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: man/figures/logo.png + twitter: + creator: "@saiemgilani" + card: summary + site: "@cfbfastR" output: html_document --- @@ -15,8 +23,8 @@ We will be using these ideas as a tool for valuation of plays with the goal of c Let’s dig in. -# The Data -We will be acquiring data from [CollegeFootballData.com](collegefootballdata.com), courtesy of @[CFB_data](https://twitter.com/CFB_data), using `cfbfastR`, created by [Saiem Gilani](https://twitter.com/saiemgilani), [Meyappan Subbaiah](https://twitter.com/msubbaiah1), and [Parker Fleming](https://twitter.com/statsowar). +## The Data +We will be acquiring data from [CollegeFootballData.com](collegefootballdata.com), courtesy of \@[CFB\_data](https://twitter.com/CFB_data), using `cfbfastR`, created by [Saiem Gilani](https://twitter.com/saiemgilani), [Akshay Easwaran](https://twitter.com/akeaswaran), [Jared Lee](https://twitter.com/JaredDLee) and [Eric Hess](https://twitter.com/arbitanalytics). # The Expected Points Model ## Outcome (target) variables diff --git a/vignettes/college-football-expected-points-model-fundamentals-part-ii.Rmd b/vignettes/college-football-expected-points-model-fundamentals-part-ii.Rmd index 26bb18c0..6b445ff5 100644 --- a/vignettes/college-football-expected-points-model-fundamentals-part-ii.Rmd +++ b/vignettes/college-football-expected-points-model-fundamentals-part-ii.Rmd @@ -1,6 +1,14 @@ --- title: "College Football Expected Points Model Fundamentals - Part II" -author: "Saiem Gilani" +description: "Motivating the regression - I do bad regression to show that a multinomial logistic regression model is necessary" +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: man/figures/logo.png + twitter: + creator: "@saiemgilani" + card: summary + site: "@cfbfastR" output: html_document --- @@ -9,127 +17,130 @@ knitr::opts_chunk$set(echo = TRUE) old <- options(rmarkdown.html_vignette.check_title = FALSE) ``` -Previously in Part 1, we left off discussing field position and expected points, including a breakdown by down. Generally, what was presented could be considered the most top-level results discussion and model definition information without much depth into how we arrived at the model, or detail on how the predictions the model provides generate the expected points. +Previously in Part 1, we left off discussing field position and expected points, including a breakdown by down. Generally, what was presented could be considered the most top-level results discussion and model definition information without much depth into how we arrived at the model, or detail on how the predictions the model provides generate the expected points. -In order to remedy that, I feel it necessary for us to cover some model building methods. This article will show you how we arrive at the model that we currently have from a modeling perspective. The entire purpose of this series of articles is to show you as transparently as I can how the Expected Points model works, how well it works, and how the model is limited. +In order to remedy that, I feel it necessary for us to cover some model building methods. This article will show you how we arrive at the model that we currently have from a modeling perspective. The entire purpose of this series of articles is to show you as transparently as I can how the Expected Points model works, how well it works, and how the model is limited. + +Additionally, and maybe most importantly, this research is reproducible. The following link contains an [R notebook](https://rpubs.com/saiemgilani/625433) and supporting figures for the article which should be sufficient to work through (it is large, \~284Mb when unzipped). [Link](https://drive.google.com/file/d/1jJZBEUvqvEC9I_0-3TFtKQGww7qICVJ2/view?usp=sharing) -Additionally, and maybe most importantly, this research is reproducible. The following link contains an [R notebook](https://rpubs.com/saiemgilani/625433) and supporting figures for the article which should be sufficient to work through (it is large, ~284Mb when unzipped). [Link](https://drive.google.com/file/d/1jJZBEUvqvEC9I_0-3TFtKQGww7qICVJ2/view?usp=sharing) - ## The Data -We will be acquiring data from [CollegeFootballData.com](collegefootballdata.com), courtesy of @[CFB_data](https://twitter.com/CFB_data), using `cfbfastR`, created by [Saiem Gilani](https://twitter.com/saiemgilani), [Meyappan Subbaiah](https://twitter.com/msubbaiah1), and [Parker Fleming](https://twitter.com/statsowar). +We will be acquiring data from [CollegeFootballData.com](collegefootballdata.com), courtesy of \@[CFB\_data](https://twitter.com/CFB_data), using `cfbfastR`, created by [Saiem Gilani](https://twitter.com/saiemgilani), [Akshay Easwaran](https://twitter.com/akeaswaran), [Jared Lee](https://twitter.com/JaredDLee) and [Eric Hess](https://twitter.com/arbitanalytics). # Regression Methods - -**Figure 1**: Regression | [Chris Albon](https://machinelearningflashcards.com/) (@[ChrisAlbon](https://twitter.com/chrisalbon?s=20)) + + +**Figure 1**: Regression \| [Chris Albon](https://machinelearningflashcards.com/) (\@[ChrisAlbon](https://twitter.com/chrisalbon?s=20)) Regression is a set of techniques for estimating relationships between multiple variables on a quantitative target variable, and our focus will be on one of the simplest types of relationships: linear. ## Linear Regression - + + **Figure 2**: Linear Regression Model ### Assumptions - - Dependent variable is continuous, unbounded, and measured on an interval or ratio scale - - Model has linear relation between independent and dependent variables - - No outliers present - - Independence Assumption: Sample observations are independent - - Absence of multicollinearity between the predictor variables - - Constant Variance Assumption (homoscedasticity) - - Normal Distribution of error terms - - Little or no auto-correlation in the residuals -Since scores in football only happen in increments of 2, 3, and 6 (+0, +1, +2), with the additional points in parentheses resulting from extra point attempts, the football scoring scheme is not continuous over an interval or ratio scale without transformation of the target variable. +- Dependent variable is continuous, unbounded, and measured on an interval or ratio scale +- Model has linear relation between independent and dependent variables +- No outliers present +- Independence Assumption: Sample observations are independent +- Absence of multicollinearity between the predictor variables +- Constant Variance Assumption (homoscedasticity) +- Normal Distribution of error terms +- Little or no auto-correlation in the residuals -While pretending I was unaware of the continuous dependent variable assumption of linear regression, I took a look into producing a linear regression model using down, distance, and yards-to-goal as independent variables using a similarly treated college football dataset but excluding all 4th down plays. I tried to predict on either the next score in the half or points on the drive, and the one that demonstrated the highest adjusted R-squared at 0.5143, the others were quite low. +Since scores in football only happen in increments of 2, 3, and 6 (+0, +1, +2), with the additional points in parentheses resulting from extra point attempts, the football scoring scheme is not continuous over an interval or ratio scale without transformation of the target variable. + +While pretending I was unaware of the continuous dependent variable assumption of linear regression, I took a look into producing a linear regression model using down, distance, and yards-to-goal as independent variables using a similarly treated college football dataset but excluding all 4th down plays. I tried to predict on either the next score in the half or points on the drive, and the one that demonstrated the highest adjusted R-squared at 0.5143, the others were quite low. Adjusted R-squared is a measure of the percentage of the dependent variable variation explained by the independent variables, in this case 51.43%. Below is the model summary of this fitting with no intercept. - + -**Figure 3**: Linear Regression model summary | Expected Drive-Points model using Down, Distance, and Field Position as factors +**Figure 3**: Linear Regression model summary \| Expected Drive-Points model using Down, Distance, and Field Position as factors Additionally, the linear model indicates that all three factors are significant at a p=0.001 level, which is at least some evidence that our variables have a relationship with drive points. Here is a plot of the linear regression model fitting. - + -**Figure 4**: Linear Regression model plots | Expected Drive-Points model using Down, Distance, and Field Position as factors +**Figure 4**: Linear Regression model plots \| Expected Drive-Points model using Down, Distance, and Field Position as factors -In the plot on the top left, there are 4 distinct scoring types clearly visible and the model is trying to fire a shot through to fit all of them. The red line in the top-left would be relatively flat if the residuals of the model fit had constant variance. While there are two other non-zero scoring types, Field Goals and Opponent Field Goals, the data excluded 4th down, so they do not appear on the plot. For clarity, there are in fact 7 next score types when we include the absence of a score, i.e. “No Score”, since the absence of a scoring event is also a type of next score. +In the plot on the top left, there are 4 distinct scoring types clearly visible and the model is trying to fire a shot through to fit all of them. The red line in the top-left would be relatively flat if the residuals of the model fit had constant variance. While there are two other non-zero scoring types, Field Goals and Opponent Field Goals, the data excluded 4th down, so they do not appear on the plot. For clarity, there are in fact 7 next score types when we include the absence of a score, i.e. "No Score", since the absence of a scoring event is also a type of next score. -Upon viewing these plots, I quickly realized that several assumptions of linear regression are being violated here, namely the constant variance assumption and normal distribution of error terms (see Figure 4), at minimum. We need to keep adding to our regression toolbox, so let us now take a look at a type of regression that does not restrict us to these assumptions. +Upon viewing these plots, I quickly realized that several assumptions of linear regression are being violated here, namely the constant variance assumption and normal distribution of error terms (see Figure 4), at minimum. We need to keep adding to our regression toolbox, so let us now take a look at a type of regression that does not restrict us to these assumptions. ## Logistic Regression -Suppose we have a binary output variable Y, let’s say Y is a variable that gives a response of 1 if the next score in the half is a TD for the offense and a 0 otherwise. If we wanted to predict the probability that the next score in the half is a TD for the offense, one of the prime candidate models would be logistic regression. - +Suppose we have a binary output variable Y, let's say Y is a variable that gives a response of 1 if the next score in the half is a TD for the offense and a 0 otherwise. If we wanted to predict the probability that the next score in the half is a TD for the offense, one of the prime candidate models would be logistic regression. -**Figure 5**: Logistic Regression [Chris Albon](https://machinelearningflashcards.com/) (@[ChrisAlbon](https://twitter.com/chrisalbon?s=20)) + +**Figure 5**: Logistic Regression [Chris Albon](https://machinelearningflashcards.com/) (\@[ChrisAlbon](https://twitter.com/chrisalbon?s=20)) - + **Figure 6**: Logistic Regression Model ### Assumptions - - Binary logistic regression requires the dependent variable to be binary (i.e. 0/1) - - There is a linear relationship between the log-odds of the outcome and each of the predictor variables. - - No outliers present - - Independence Assumption: Sample observations are independent - - Absence of multicollinearity between the predictor variables - - ~~Constant Variance Assumption (homoscedasticity)~~ - - ~~Normal Distribution of error terms~~ - - ~~Little or no auto-correlation in the residuals~~ - -Now we are attempting to calculate the probability of the next scoring event directly, an essential component of an expected points model. Once we have a model capable of calculating the expectation of the scoring event, e.g. the probability of the next score being an offense touchdown, then we simply have to multiply the probability by the point value of the score to get the expected points. +- Binary logistic regression requires the dependent variable to be binary (i.e. 0/1) +- There is a linear relationship between the log-odds of the outcome and each of the predictor variables. +- No outliers present +- Independence Assumption: Sample observations are independent +- Absence of multicollinearity between the predictor variables +- ~~Constant Variance Assumption (homoscedasticity)~~ +- ~~Normal Distribution of error terms~~ +- ~~Little or no auto-correlation in the residuals~~ + +Now we are attempting to calculate the probability of the next scoring event directly, an essential component of an expected points model. Once we have a model capable of calculating the expectation of the scoring event, e.g. the probability of the next score being an offense touchdown, then we simply have to multiply the probability by the point value of the score to get the expected points. - + -**Figure 7**: Logistic vs. Linear Regression | [Chris Albon](https://machinelearningflashcards.com/) (@[ChrisAlbon](https://twitter.com/chrisalbon?s=20)) +**Figure 7**: Logistic vs. Linear Regression \| [Chris Albon](https://machinelearningflashcards.com/) (\@[ChrisAlbon](https://twitter.com/chrisalbon?s=20)) -With that background, we can build our model equation with whatever independent variables we choose to include in the model as shown in Figure 8. +With that background, we can build our model equation with whatever independent variables we choose to include in the model as shown in Figure 8. - + **Figure 8**: Offense Touchdown Logit Regression -Below is a model fit to the next score offense touchdown variable using the independent variables yards-to-goal, down, distance, and the interaction between down and distance. +Below is a model fit to the next score offense touchdown variable using the independent variables yards-to-goal, down, distance, and the interaction between down and distance. - + **Figure 9**: Offense Touchdown Logistic Regression model summary -Once again we see that all variables in the model are fit are significant at the p < 0.001 level. In figure 10 below, we can see the probability of the next score in half being a touchdown in relation to field position (yards-to-goal) as the offense progresses down the field. +Once again we see that all variables in the model are fit are significant at the p \< 0.001 level. In figure 10 below, we can see the probability of the next score in half being a touchdown in relation to field position (yards-to-goal) as the offense progresses down the field. - + **Figure 10**: Field Position and Offense TD probability - Logistic Regression -You might be asking “Yeah, that’s great, but you’re still only predicting the probability of one scoring type relative to another. You’d need to do this like 6 times, right?” Well, fair point. How does one do logistic regression on a categorical variable that has more than one class? +You might be asking "Yeah, that's great, but you're still only predicting the probability of one scoring type relative to another. You'd need to do this like 6 times, right?" Well, fair point. How does one do logistic regression on a categorical variable that has more than one class? ## Multinomial Logistic Regression (or Softmax regression) -A multinomial logistic regression model uses the independent (predictor) variables and target variable data from the training set to build relationships between the independent variables and each of the classes of the target variable. +A multinomial logistic regression model uses the independent (predictor) variables and target variable data from the training set to build relationships between the independent variables and each of the classes of the target variable. - + -**Figure 11**: Multinomial Logistic Regression [Chris Albon](https://machinelearningflashcards.com/) (@[ChrisAlbon](https://twitter.com/chrisalbon?s=20)) +**Figure 11**: Multinomial Logistic Regression [Chris Albon](https://machinelearningflashcards.com/) (\@[ChrisAlbon](https://twitter.com/chrisalbon?s=20)) -The primary difference between logistic and multinomial logistic regression is the use of the softmax function which re-weights the probabilities generated from each of the individual models so that in total they add to one as seen in Figure 12 below. +The primary difference between logistic and multinomial logistic regression is the use of the softmax function which re-weights the probabilities generated from each of the individual models so that in total they add to one as seen in Figure 12 below. - + **Figure 12**: Softmax function -More specifically, a multinomial logistic regression model is an extension of the binomial logistic regression model because it is a series of logistic regression models estimated simultaneously with the same reference outcome. +More specifically, a multinomial logistic regression model is an extension of the binomial logistic regression model because it is a series of logistic regression models estimated simultaneously with the same reference outcome. - + **Figure 13**: Multinomial Logistic Regression Football Expected Points Model -The college football expected points (EP) model is a multinomial logistic regression model which generates probabilities for the possible types of next score events within the same half. In our case, we build 6 logistic regression models fit to the next score types — Offense FG, Offense TD, Offense Safety, Opponent TD, Opponent FG, and Opponent Safety — all except for the class that is used as the base case (i.e. No Score), since that is accounted for in the intercept, as mentioned in Part 1. Ron Yurko, Sam Ventura, and Max Horowitz originally proposed the multinomial logistic regression expected points model for football in 2017, which we will learn more about in Part 3. +The college football expected points (EP) model is a multinomial logistic regression model which generates probabilities for the possible types of next score events within the same half. In our case, we build 6 logistic regression models fit to the next score types --- Offense FG, Offense TD, Offense Safety, Opponent TD, Opponent FG, and Opponent Safety --- all except for the class that is used as the base case (i.e. No Score), since that is accounted for in the intercept, as mentioned in Part 1. Ron Yurko, Sam Ventura, and Max Horowitz originally proposed the multinomial logistic regression expected points model for football in 2017, which we will learn more about in Part 3. Additionally, now that we have a way to calculate the probabilities of scores, we can calculate the expected points. We will discuss this in Part 4. diff --git a/vignettes/college-football-expected-points-model-fundamentals-part-iii.Rmd b/vignettes/college-football-expected-points-model-fundamentals-part-iii.Rmd index a4a41526..4aef6118 100644 --- a/vignettes/college-football-expected-points-model-fundamentals-part-iii.Rmd +++ b/vignettes/college-football-expected-points-model-fundamentals-part-iii.Rmd @@ -1,6 +1,14 @@ --- title: "College Football Expected Points Model Fundamentals - Part III" -author: "Saiem Gilani" +description: "A brief history of expected points models. Learn about Virgil Carter's 1970 paper and the origins of the nflscrapR expected points model (which the cfbscrapR package used). The cfbfastR package includes support for this model as well." +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: man/figures/logo.png + twitter: + creator: "@saiemgilani" + card: summary + site: "@cfbfastR" output: html_document --- @@ -17,7 +25,7 @@ The entire purpose of these series of articles is to show you as transparently a ## The Data -We will be acquiring data from [CollegeFootballData.com](collegefootballdata.com), courtesy of @[CFB_data](https://twitter.com/CFB_data), using `cfbfastR`, created by [Saiem Gilani](https://twitter.com/saiemgilani), [Meyappan Subbaiah](https://twitter.com/msubbaiah1), and [Parker Fleming](https://twitter.com/statsowar). +We will be acquiring data from [CollegeFootballData.com](collegefootballdata.com), courtesy of \@[CFB\_data](https://twitter.com/CFB_data), using `cfbfastR`, created by [Saiem Gilani](https://twitter.com/saiemgilani), [Akshay Easwaran](https://twitter.com/akeaswaran), [Jared Lee](https://twitter.com/JaredDLee) and [Eric Hess](https://twitter.com/arbitanalytics). # An Abridged History of Expected Points Models in Football ## Field Position models @@ -67,7 +75,7 @@ His other consideration was that he limited the data to plays where the score di Trey Causey did a quality write-up on a very similar style [model](http://thespread.us/expected-points.html) and has done some interesting [nearest-neighbors](http://thespread.us/clustering.html) player similarity modeling that is worth reading and, at the time, was reproducible. -So all of these models are curve fitting attempts that lead us to the topic of regression. Let us survey different types of regression before continuing. +So all of these models are curve fitting attempts that lead us to the topic of regression. ## Game-State Situational Probability models Alok Pattani’s 2012 writeup on [ESPN’s NFL Expected Points model](https://www.espn.com/nfl/story/_/id/8379024/nfl-explaining-expected-points-metric), which additionally included home-field advantage and time remaining, left a lot of the detail out, giving few reproducible details. @@ -76,7 +84,7 @@ However, in subsequent years, more details regarding the technical specifics of Additionally, Kenneth Goldner wrote a paper in 2017 about using a Markov modeling of a possession with stochastic processes which I have been unable to get my hands on. EDIT: A very kind Columbia professor saw this article and sent me the paper. Among other things, the paper demonstrates that on 1st and 10 at any point on the field, the expected points is positive. -In 2017, Ron Yurko, Sam Ventura, and Max Horowitz from the Carnegie Mellon University Statistics department started presenting “[NFL Player Evaluation Using Expected Points Added with nflscrapR](https://www.stat.cmu.edu/~ryurko/files/greatlakes_2017.pdf)” at conferences and ultimately published the [nflWAR](https://www.degruyter.com/view/journals/jqas/15/3/article-p163.xml?tab_body=pdf-74962) paper in the Journal of Quantitative Analysis in Sports. +In 2017, Ron Yurko, Sam Ventura, and Max Horowitz from Carnegie Mellon University's Statistics department started presenting “[NFL Player Evaluation Using Expected Points Added with nflscrapR](https://www.stat.cmu.edu/~ryurko/files/greatlakes_2017.pdf)” at conferences and ultimately published the [nflWAR](https://www.degruyter.com/view/journals/jqas/15/3/article-p163.xml?tab_body=pdf-74962) paper in the Journal of Quantitative Analysis in Sports. (That is a seminal work in football analytics and if you were to only click one link to read more on, that is the paper you should look at.) diff --git a/vignettes/fourth-down-plot-tutorial.Rmd b/vignettes/fourth-down-plot-tutorial.Rmd index 3a404e3d..a426279b 100644 --- a/vignettes/fourth-down-plot-tutorial.Rmd +++ b/vignettes/fourth-down-plot-tutorial.Rmd @@ -1,7 +1,15 @@ --- title: "Creating Fourth Down Tendency Plots Using cfbfastR" -author: "Michael Egle | @deceptivespeed_" +description: "A rundown of the Big XII returning coaches fourth down tendencies" +author: "Michael Egle
@deceptivespeed_ @michaelegle" date: "9/5/2020" +opengraph: + image: + src: man/figures/logo.png + twitter: + site: "@cfbfastR" + card: summary + creator: "@deceptivespeed_" output: html_document --- @@ -9,8 +17,6 @@ output: html_document knitr::opts_chunk$set(echo = TRUE) ``` -@deceptivespeed_ @michaelegle - Hey everyone, my name is Michael and over the summer I worked on a daily series of plots using ```ggplot``` and the ```cfbfastR``` package. One of my favorite plots I put together was the fourth down tendency plot for various head coaches. This visualization was inspired by Michael Lopez doing the same thing for NFL coaches. This tutorial is going to walk through how they're put together. If you haven't already, you should read the introduction tutorial that Parker made to get used to the data and download the package. ## First, we'll have to install and import the necessary packages @@ -19,7 +25,7 @@ if (!requireNamespace('pacman', quietly = TRUE)){ install.packages('pacman') } pacman::p_load(tidyverse) -pacman::p_load_gh("saiemgilani/cfbfastR") +pacman::p_load_current_gh("saiemgilani/cfbfastR") ``` diff --git a/vignettes/intro.Rmd b/vignettes/intro.Rmd new file mode 100644 index 00000000..7c3777a8 --- /dev/null +++ b/vignettes/intro.Rmd @@ -0,0 +1,97 @@ +--- +title: "Introduction to cfbfastR" +description: "Getting started with using cfbfastR and college football analytics." +author: "Saiem Gilani
@saiemgilani @saiemgilani" +opengraph: + image: + src: man/figures/logo.png + twitter: + site: "@cfbfastR" + card: summary + creator: "@saiemgilani" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +pacman::p_load_current_gh("r-lib/pkgapi") +library(pkgapi) +pkg <- pkgapi::map_package(path = "../") +library(dplyr) +exported <- pkg$defs %>% dplyr::filter(exported == TRUE) +cfbd_funcs <- sum(stringr::str_detect(exported$file,"cfbd")) - sum(stringr::str_detect(exported$file,"cfbd_pbp_data")) +pkg_name <- "saiemgilani/cfbfastR" +url <- paste0("https://raw.githubusercontent.com/", pkg_name, "/master/DESCRIPTION") + + +x <- readLines(url) +remote_version <- gsub("Version:\\s*", "", x[grep('Version:', x)]) +``` + +Hey folks, + +Welcome to the football analytics community! I'm Saiem Gilani, one of the [authors](https://saiemgilani.github.io/cfbfastR/authors.html "Authors and contributors to cfbfastR") of [`cfbfastR`](https://twitter.com/cfbfastR "Follow @cfbfastR on Twitter! Tag us in your tweets using cfbfastR and we'll share it!"), and I hope to give the community a high-quality resource for accessing college football data for statistical analysis, football research, and more. I am excited to show you some of what you can do with this edition of the package. + +### **The Data** +There are generally speaking **three** college football data sources accessed from this package: + +- [`cfbfastR-data` repo](https://github.com/saiemgilani/cfbfastR-data) [![Twitter Follow](https://img.shields.io/twitter/follow/cfbfastR?color=blue&label=%40cfbfastR&logo=twitter&style=for-the-badge)](https://twitter.com/cfbfastR) +- [College Football Data API](https://collegefootballdata.com) [![Twitter Follow](https://img.shields.io/twitter/follow/cfb_data?color=blue&label=%40cfb_data&logo=twitter&style=for-the-badge)](https://twitter.com/cfb_data) +- [ESPN](https://espn.com) + +#### **Function names indicate the data source** + +* Functions that use the [`cfbfastR-data` repository](https://github.com/saiemgilani/cfbfastR-data) will contain `_cfb` or `cfb_` in the function name and would be considered loading functions for the play-by-play data. + +* Functions that use the CFB Data API start with `cfbd_` by convention and should be assumed as `get` functions. + +* Functions that use one of ESPN's APIs start with `espn_` by convention and should be assumed as `get` functions. There are only two of these functions so far: `espn_ratings_fpi()` and `espn_metrics_wp()` + +However, there is only one data *provider* involved for most game data, ESPN's data provider. + +As of `cfbfastR` version `r remote_version`, the package exports `r nrow(exported)` functions. The bulk (\~`r cfbd_funcs`) of the functions within the package serve as the unofficial R API client for the [College Football Data API](https://collegefootballdata.com). + +#### **CFB Data now requires an API key (it's free)** +- Starting on April 1, 2021, the College Football Data API requires [key authentication](https://collegefootballdata.com/key), but the **key is free to acquire and use**. + +- [Follow the instructions](https://collegefootballdata.com/key) and wait for your API key to be delivered to the e-mail account associated with your key. + +#### **Using the CFB Data key** + +You can save the key for consistent usage by adding `CFBD_API_KEY=XXXX-YOUR-API-KEY-HERE-XXXXX` to your .REnviron file (easily accessed via [**`usethis::edit_r_environ()`**](https://usethis.r-lib.org/reference/edit.html)). + +Run [**`usethis::edit_r_environ()`**](https://usethis.r-lib.org/reference/edit.html) and THEN paste the following in the new script that pops up (with**out** quotations) + +``` {.r} +CFBD_API_KEY = XXXX-YOUR-API-KEY-HERE-XXXXX +``` + +For less consistent usage, save your API key as the environment variable `CFBD_API_KEY` (with quotations) at the beginning of every session, using a command like the following. + +```{r} +Sys.setenv(CFBD_API_KEY = "XXXX-YOUR-API-KEY-HERE-XXXXX") +``` + + +If you have ever worked with the now archived [`cfbscrapR`](https://github.com/saiemgilani/cfbscrapR) package, most of the functions in ```cfbfastR``` should be fairly familiar with some slight changes. + +#### **Load and install the necessary packages** +```{r load_cfbfastR_tidy} +if (!requireNamespace('pacman', quietly = TRUE)){ + install.packages('pacman') +} +pacman::p_load_current_gh("saiemgilani/cfbfastR") +pacman::p_load(tidyverse, zoo, ggimage, gt) +``` + +We are going to load in data for seasons 2014-2020, it'll take between 45-90 seconds to run. +```{r load_2014_2020, warning = FALSE} +tictoc::tic() +pbp <- data.frame() +seasons <- 2014:2020 +progressr::with_progress({ +future::plan("multisession") + pbp <- cfbfastR::load_cfb_pbp(seasons) +}) +tictoc::toc() +``` diff --git a/vignettes/nth-rated-recruit.Rmd b/vignettes/nth-rated-recruit.Rmd index ee0c4e92..a1206d62 100644 --- a/vignettes/nth-rated-recruit.Rmd +++ b/vignettes/nth-rated-recruit.Rmd @@ -1,14 +1,20 @@ --- title: "Visualizing Team Talent from Player Recruiting Rankings" -author: "Eric Hess - Arbitrary Analytics (@arbitanalytics)" +description: "A quick way to visually approximate how much talent each school recruited using cfbfastR and ggplot2." +author: "Eric Hess - Arbitrary Analytics
@arbitanalytics @ehess" +opengraph: + image: + src: "https://github.com/saiemgilani/cfbfastR-data/blob/master/themes/social_card_cfbfastR_final_quote.png?raw=true" + twitter: + site: "@cfbfastR" + card: summary_large_image + creator: "@arbitanalytics" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE) ``` -@arbitanalytics -@ehess Hi ```cfbfastR``` users, I'm Eric Hess and I run the [Twitter account](https://twitter.com/arbitanalytics) and blog called [Arbitrary Analytics](https://arbitraryanalytics.com/). My work focuses on sports analytics mainly for Nebraska and the Big Ten. Today, I'm going to walk through how I used the ```cfbfastR``` package to make a simple plot of recent recruiting classes. The final output will give you a quick way to visually approximate how much talent each school has recruited. I'm going to assume you have a basic understanding of working with R and that your development environment is already setup. @@ -19,7 +25,7 @@ if (!requireNamespace('pacman', quietly = TRUE)){ install.packages('pacman') } pacman::p_load(dplyr, ggplot2) -pacman::p_load_gh("saiemgilani/cfbfastR") +pacman::p_load_current_gh("saiemgilani/cfbfastR") ``` To create the plot I'm going to use two functions from ```cfbfastR```. The first is the ```cfbd_team_info``` function. I'm going to pass ```"B1G"``` to the function for the ```conference``` argument to get info for just Big Ten teams. The next function I'm going to use is the ```cfbd_recruiting_player``` function. The apply function allows me to run the given function for each item in the data frame I pass to it. In this case I run it for each team in the Big Ten. I'm calling this function four times to get each year's class. I'll combine all of these into one large data frame with every team's recruits. For the sake of simplicity, I am only using High School recruits as shown by the ```recruit_type``` argument. You can also get Prep School recruits (```recruit_type = "PrepSchool"```) or junior college recruits (```recruit_type = "JUCO"```). I also have the loop pause for 5 seconds between each team. While this causes the function to take a little longer to run it also helps with server load on the back end. diff --git a/vignettes/rolling-epa-graph.rmd b/vignettes/rolling-epa-graph.rmd index 4a1a024e..321ca49f 100644 --- a/vignettes/rolling-epa-graph.rmd +++ b/vignettes/rolling-epa-graph.rmd @@ -1,12 +1,17 @@ --- title: "Rolling EPA Graph" -author: "Nate Manzo (@cfbnate)" +description: "IT'S GRAPHIN' TIME
^To be said in an extremely Power Rangers voice^" +author: "Nate Manzo
@cfbnate @natemanzo" +opengraph: + image: + src: "https://github.com/saiemgilani/cfbfastR-data/blob/master/themes/social_card_cfbfastR_final_quote.png?raw=true" + twitter: + creator: "@cfbnate" + card: summary + site: "@cfbfastR" output: html_document --- -@cfbnate -@natemanzo - This vignette will use data from the ```cfbfastR``` package to create a moving average graph of offensive EPA over the course of a season. This lets us visualize how a team's performance has changed over time and compare that performance to other teams around the country. ## Load and Install the necessary packages @@ -15,7 +20,7 @@ if (!requireNamespace('pacman', quietly = TRUE)){ install.packages('pacman') } pacman::p_load(tidyverse, zoo, ggimage) -pacman::p_load_gh("saiemgilani/cfbfastR") +pacman::p_load_current_gh("saiemgilani/cfbfastR") ``` ## Pull the play by play data @@ -207,6 +212,6 @@ ggsave(graph_team_off, filename = paste0("off_epa_rolling_",team,".png"), dpi = 300, type = "cairo", width = 10, height = 7, units = "in") ``` -I hope you found this useful! As always, thanks to [\@CFB_Data](https://twitter.com/CFB_Data) and the [\@cfbfastR](https://twitter.com/cfbfastR) team for making this possible. And shout out to folks like Parker Fleming and Meyappan Subbaiah for their feedback, advice, and encouragement while refining the look of this visualization. Tag me in any of these graphs you post on twitter and I'll share them as much as possible. +I hope you found this useful! As always, thanks to [\@CFB_Data](https://twitter.com/CFB_Data) and the [\@cfbfastR](https://twitter.com/cfbfastR) team for making this possible. And shout out to folks like Parker Fleming ([\@statsowar](https://twitter.com/statsowar)) and Meyappan Subbaiah ([\@msubbiah1](https://twitter.com/msubbiah1)) for their feedback, advice, and encouragement while refining the look of this visualization. Tag me in any of these graphs you post on twitter and I'll share them as much as possible. -[Nate Manzo](https://twitter.com/cfbNate)