Skip to content

Commit

Permalink
man
Browse files Browse the repository at this point in the history
  • Loading branch information
saiemgilani committed Jun 1, 2022
1 parent 80573cb commit 4c02a4a
Show file tree
Hide file tree
Showing 44 changed files with 217 additions and 312 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
cfb_pbp_db
^CRAN-RELEASE$
^\.pre-commit-config\.yaml$
^man_backup$
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.0
Config/testthat/edition: 3
8 changes: 1 addition & 7 deletions R/cfb_pbp.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#' **Load cfbfastR play-by-play**
#' @name load_cfb_pbp
NULL
#' @title
#' **Load cleaned play-by-play 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.
Expand Down Expand Up @@ -54,8 +50,6 @@ load_games <- function(){
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`
Expand All @@ -72,7 +66,7 @@ load_games <- function(){
#' by play data table either for the whole cfbfastR era (with `force_rebuild = TRUE`)
#' or just for specified seasons (e.g. `force_rebuild = c(2019, 2020)`).
#' Please note the following behavior:
#' \describe{
#' \itemize{
#' \item{`force_rebuild = TRUE`}{: The data table with the name `tblname`
#' will be removed completely and rebuilt from scratch. This is helpful when
#' new columns are added during the Off-Season.}
Expand Down
73 changes: 31 additions & 42 deletions R/cfbd_betting.R
Original file line number Diff line number Diff line change
@@ -1,57 +1,42 @@
#' **CFBD Betting Lines Endpoint Overview**
#' @name cfbd_betting
NULL

#' @title
#' **CFBD Betting Lines Endpoint Overview**
#' @rdname cfbd_betting
#' @description
#' **Get betting lines information for games**
#' ```r
#' cfbd_betting_lines(year = 2018, week = 12, team = "Florida State")
#'
#' cfbd_betting_lines(year = 2018, week = 13, team = "Texas A&M", conference = "SEC")
#' ```
#' @examples
#' \donttest{
#' try(cfbd_betting_lines(year = 2018, week = 12, team = "Florida State"))
#' try(cfbd_betting_lines(year = 2018, week = 13, team = "Texas A&M", conference = "SEC"))
#' }
#' @param game_id (*Integer* optional): Game ID filter for querying a single game
#' @title **CFBD Betting Lines Endpoint Overview**
#' @description **Get betting lines information for games**
#' @param game_id (*Integer* optional): Game ID filter for querying a single game \cr
#' Can be found using the [cfbd_game_info()] function
#' @param year (*Integer* required): Year, 4 digit format(*YYYY*)
#' @param week (*Integer* optional): Week - values from 1-15, 1-14 for seasons pre-playoff (i.e. 2013 or earlier)
#' @param season_type (*String* default regular): Select Season Type: regular or postseason
#' @param team (*String* optional): D-I Team
#' @param home_team (*String* optional): Home D-I Team
#' @param away_team (*String* optional): Away D-I Team
#' @param conference (*String* optional): Conference abbreviation - Select a valid FBS conference
#' Conference abbreviations P5: ACC, B12, B1G, SEC, PAC
#' Conference abbreviations G5 and FBS Independents: CUSA, MAC, MWC, Ind, SBC, AAC
#' @param conference (*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 line_provider (*String* optional): Select Line Provider - Caesars, consensus, numberfire, or teamrankings
#' @return Betting information for games with the following columns:
#'
#' \describe{
#' \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{`start_date`:character.}{Start Date}
#' \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{`spread_open`:character.}{Opening spread for the game.}
#' \item{`over_under`:character.}{Over/Under for the game.}
#' \item{`over_under_open`:character.}{Opening over/under for the game.}
#' \item{`home_moneyline`:character.}{Home team moneyline.}
#' \item{`away_moneyline`:character.}{Away team moneyline.}
#' \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{start_date:character.}{Start Date}
#' \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{spread_open:character.}{Opening spread for the game.}
#' \item{over_under:character.}{Over/Under for the game.}
#' \item{over_under_open:character.}{Opening over/under for the game.}
#' \item{home_moneyline:character.}{Home team moneyline.}
#' \item{away_moneyline:character.}{Away team moneyline.}
#' }
#' @keywords Betting Lines
#'
#' @importFrom jsonlite fromJSON
#' @importFrom httr GET
#' @importFrom utils URLencode
Expand All @@ -62,6 +47,10 @@ NULL
#' @importFrom dplyr filter as_tibble rename
#' @importFrom tidyr unnest
#' @export
#' @examples
#' \donttest{
#' try(cfbd_betting_lines(year = 2018, week = 12, team = "Florida State"))
#' }
cfbd_betting_lines <- function(game_id = NULL,
year = NULL,
week = NULL,
Expand Down
8 changes: 2 additions & 6 deletions R/cfbd_coaches.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#' @name cfbd_coaches
#' @aliases coaches cfbd_coaches
#' @title
#' **CFBD Coaches Endpoint Overview**
#' @description
#' **Coach information search**
#' A coach search function which provides coaching records and school history for a given coach
#' ```
#' cfbd_coaches(first = "Nick", last = "Saban", team = "alabama")
#' ````
#'
#' @param first (*String* optional): First name for the coach you are trying to look up
#' @param last (*String* optional): Last name for the coach you are trying to look up
#' @param team (*String* optional): Team - Select a valid team, D1 football
Expand Down Expand Up @@ -43,7 +39,7 @@
#' @import purrr
#' @export
#' @examples
#'\donttest{
#' \donttest{
#' try(cfbd_coaches(first = "Nick", last = "Saban", team = "alabama"))
#' }
cfbd_coaches <- function(first = NULL,
Expand Down
16 changes: 5 additions & 11 deletions R/cfbd_conferences.R
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
#' @name cfbd_conferences
#' @aliases conferences cfbd_conferences
#' @title
#' **CFBD Conferences Endpoint Overview**
#' @description
#' **Get college football conference information**
#' Pulls all college football conferences and returns as data frame
#' You can call this function simply with:
#' ```r
#' cfbd_conferences()
#' ```
#' @examples
#' \donttest{
#' try(cfbd_conferences())
#' }
#'
#' @return [cfbd_conferences()] - A data frame with 94 rows and 5 variables:
#' \describe{
#' \item{`conference_id`:}{Referencing conference id.}
#' \item{`name`:}{Conference name.}
#' \item{`long_name`:}{Long name for Conference.}
#' \item{`abbreviation`:}{Conference abbreviation.}
#' \item{`classification`:}{Conference classification (fbs,fcs,ii,iii)}
#' ...
#' }
#' @keywords Conferences
#' @importFrom jsonlite fromJSON
#' @importFrom httr GET
#' @import dplyr
#' @import tidyr
#' @export
#' @examples
#' \donttest{
#' try(cfbd_conferences())
#' }
cfbd_conferences <- function() {
full_url <- "https://api.collegefootballdata.com/conferences"

Expand Down
5 changes: 3 additions & 2 deletions R/cfbd_draft.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#' ````
#'
NULL

#' @title
#' **Get list of NFL teams**
#' @return [cfbd_draft_teams()] - A data frame with 4 variables:
Expand Down Expand Up @@ -170,6 +171,7 @@ cfbd_draft_positions <- function() {
)
return(df)
}

#' @title
#' **Get list of NFL draft picks**
#' @param year (*Integer* required): NFL draft class, 4 digit format (*YYYY*)
Expand Down Expand Up @@ -215,10 +217,9 @@ cfbd_draft_positions <- function() {
#' \donttest{
#' try(cfbd_draft_picks(year = 2020))
#'
#' ### **ROBERTOOOOOOOOOOOOOOOOOO**
#' try(cfbd_draft_picks(year = 2016, position = "PK"))
#' }
#'

cfbd_draft_picks <- function(year = NULL,
nfl_team = NULL,
college = NULL,
Expand Down
17 changes: 6 additions & 11 deletions R/cfbd_drives.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@
#' **CFBD Drives Endpoint**
#' @description
#' **Get college football game drives**
#' ```r
#' cfbd_drives(2018, week = 1, team = "TCU")
#'
#' cfbd_drives(2018, team = "Texas A&M", defense_conference = "SEC")
#' ````
#' @examples
#' \donttest{
#' try(fbd_drives(2018, week = 1, team = "TCU"))
#'
#' try(cfbd_drives(2018, team = "Texas A&M", defense_conference = "SEC"))
#' }
#' @param year (*Integer* required): Year, 4 digit format (*YYYY*)
#' @param season_type (*String* default regular): Select Season Type: regular, postseason, or both
#' @param week (*Integer* optional): Week - values from 1-15, 1-14 for seasons pre-playoff, i.e. 2013 or earlier
Expand Down Expand Up @@ -69,6 +58,12 @@
#' @import dplyr
#' @import tidyr
#' @export
#' @examples
#' \donttest{
#' try(fbd_drives(2018, week = 1, team = "TCU"))
#'
#' try(cfbd_drives(2018, team = "Texas A&M", defense_conference = "SEC"))
#' }
cfbd_drives <- function(year,
season_type = "regular",
week = NULL,
Expand Down
1 change: 1 addition & 0 deletions R/cfbd_games.R
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ cfbd_game_records <- function(year,
#' \item{`total_penalties_yards_allowed`: character.}{Opponent total penalty yards.}
#' \item{`possession_time_allowed`: character.}{Opponent time of possession.}
#' }
#'
#' @keywords Team Game Stats
#' @importFrom jsonlite fromJSON
#' @importFrom httr GET RETRY
Expand Down
15 changes: 8 additions & 7 deletions R/cfbd_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#' \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.}
#' }
#'
#' @details
#' ### **Get team game averages for predicted points added (PPA)**
#' ```r
#' cfbd_metrics_ppa_games(year = 2019, team = "TCU")
Expand All @@ -36,7 +38,6 @@
#' ```r
#' cfbd_metrics_ppa_predicted(down = 1, distance = 10)
#' ```
#'
NULL
#' @title
#' **Get team game averages for predicted points added (PPA)**
Expand Down Expand Up @@ -82,7 +83,7 @@ NULL
#' \donttest{
#' try(cfbd_metrics_ppa_games(year = 2019, team = "TCU"))
#' }
#'

cfbd_metrics_ppa_games <- function(year,
week = NULL,
team = NULL,
Expand Down Expand Up @@ -212,7 +213,7 @@ cfbd_metrics_ppa_games <- function(year,
#' \donttest{
#' try(cfbd_metrics_ppa_players_games(year = 2019, week = 3, team = "TCU"))
#' }
#'

cfbd_metrics_ppa_players_games <- function(year = NULL,
week = NULL,
team = NULL,
Expand Down Expand Up @@ -509,7 +510,7 @@ cfbd_metrics_ppa_players_season <- function(year = NULL,
#'
#' try(cfbd_metrics_ppa_predicted(down = 3, distance = 10))
#' }
#'

cfbd_metrics_ppa_predicted <- function(down,
distance) {
# Check if down is numeric
Expand Down Expand Up @@ -613,7 +614,7 @@ cfbd_metrics_ppa_predicted <- function(down,
#' \donttest{
#' try(cfbd_metrics_ppa_teams(year = 2019, team = "TCU"))
#' }
#'

cfbd_metrics_ppa_teams <- function(year = NULL,
team = NULL,
conference = NULL,
Expand Down Expand Up @@ -726,7 +727,7 @@ cfbd_metrics_ppa_teams <- function(year = NULL,
#' \donttest{
#' try(cfbd_metrics_wp_pregame(year = 2019, week = 9, team = "Texas A&M"))
#' }
#'

cfbd_metrics_wp_pregame <- function(year = NULL,
week = NULL,
team = NULL,
Expand Down Expand Up @@ -843,7 +844,7 @@ cfbd_metrics_wp_pregame <- function(year = NULL,
#' \donttest{
#' try(cfbd_metrics_wp(game_id = 401012356))
#' }
#'

cfbd_metrics_wp <- function(game_id) {


Expand Down
Loading

0 comments on commit 4c02a4a

Please sign in to comment.