Skip to content

Commit

Permalink
add to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tanho63 committed Aug 8, 2023
1 parent 7a0e36b commit 51acee7
Show file tree
Hide file tree
Showing 67 changed files with 107 additions and 39 deletions.
6 changes: 6 additions & 0 deletions R/from_url.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' @return a dataframe, possibly of type `nflverse_data`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' urls <- c("https://github.com/nflverse/nflverse-data/releases/download/rosters/roster_2020.csv",
Expand Down Expand Up @@ -48,6 +49,7 @@ load_from_url <- function(url, ..., seasons = TRUE, nflverse = FALSE){
#' @return a dataframe as created by [`readRDS()`]
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' rds_from_url("https://github.com/nflverse/nflverse-data/releases/download/test/combines.rds")
Expand Down Expand Up @@ -80,6 +82,7 @@ rds_from_url <- function(url) {
#' @return a dataframe as created by [`data.table::fread()`]
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' csv_from_url("https://github.com/nflverse/nflverse-data/releases/download/test/combines.csv")
Expand All @@ -102,6 +105,7 @@ csv_from_url <- function(...){
#' @return a raw vector
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents CRAN errors
#' head(raw_from_url(
Expand Down Expand Up @@ -138,6 +142,7 @@ raw_from_url <- function(url){
#' @return a dataframe as parsed by [`arrow::read_parquet()`]
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({
#' parquet_from_url(
Expand Down Expand Up @@ -175,6 +180,7 @@ parquet_from_url <- function(url){
#' @return a dataframe as parsed by [`qs::qdeserialize()`]
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({
#' qs_from_url(
Expand Down
1 change: 1 addition & 0 deletions R/load_combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' @param file_type One of `c("rds", "qs", "csv", "parquet")`. Can also be set globally with
#' `options(nflreadr.prefer)`
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_combine()
Expand Down
1 change: 1 addition & 0 deletions R/load_contracts.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' Can also be set globally with options(nflreadr.prefer)
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_contracts()
Expand Down
1 change: 1 addition & 0 deletions R/load_depth_charts.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' `options(nflreadr.prefer)`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_depth_charts(2020)
Expand Down
1 change: 1 addition & 0 deletions R/load_draft_picks.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' `options(nflreadr.prefer)`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_draft_picks()
Expand Down
1 change: 1 addition & 0 deletions R/load_espn_qbr.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @param summary_type One of "season" or "weekly", defaults to season
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' load_espn_qbr("nfl",2020)
#' }
Expand Down
1 change: 1 addition & 0 deletions R/load_ffverse.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @return a dataframe of player IDs
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_ff_playerids()
Expand Down
1 change: 1 addition & 0 deletions R/load_injuries.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' `options(nflreadr.prefer)`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({# prevents cran errors
#' load_injuries(2020)
Expand Down
1 change: 1 addition & 0 deletions R/load_nextgen_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#'
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_nextgen_stats(stat_type = "passing")
Expand Down
1 change: 1 addition & 0 deletions R/load_officials.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' `options(nflreadr.prefer)`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_officials()
Expand Down
1 change: 1 addition & 0 deletions R/load_participation.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' @return A dataframe of participation data, optionally merged with play by play
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_participation(seasons = 2020, include_pbp = TRUE)
Expand Down
1 change: 1 addition & 0 deletions R/load_pbp.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' (see below) for all given `seasons`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_pbp(2019:2020)
Expand Down
2 changes: 2 additions & 0 deletions R/load_pfr_advstats.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' @param seasons a numeric vector specifying what seasons to return, if `TRUE` returns all available data
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' load_pfr_passing()
#' }
Expand Down Expand Up @@ -38,6 +39,7 @@ load_pfr_passing <- function(seasons = TRUE){
#'
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_pfr_advstats()
Expand Down
1 change: 1 addition & 0 deletions R/load_player_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' `options(nflreadr.prefer)`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_player_stats()
Expand Down
1 change: 1 addition & 0 deletions R/load_players.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' `options(nflreadr.prefer)`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_players()
Expand Down
1 change: 1 addition & 0 deletions R/load_rosters.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' `options(nflreadr.prefer)`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_rosters(2020)
Expand Down
1 change: 1 addition & 0 deletions R/load_rosters_weekly.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' `options(nflreadr.prefer)`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_rosters_weekly(2020)
Expand Down
1 change: 1 addition & 0 deletions R/load_schedules.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nfldata>
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_schedules(2020)
Expand Down
1 change: 1 addition & 0 deletions R/load_snap_counts.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' `options(nflreadr.prefer)`
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents CRAN errors
#' load_snap_counts()
Expand Down
3 changes: 2 additions & 1 deletion R/load_teams.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#'
#' @description Loads team graphics, colors, and logos - useful for plots!
#'
#' @param current If `TRUE` (the default), returns a standardized list of current teams only,
#' @param current If `TRUE` (the default), returns a standardized list of current teams only,
#' with abbreviations as per [nflreadr::team_abbr_mapping].
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#' load_teams()
Expand Down
1 change: 1 addition & 0 deletions R/load_trades.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @seealso Issues with this data should be filed here: <https://github.com/nflverse/nfldata>
#'
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' load_trades(2020)
#' }
Expand Down
1 change: 0 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ print.nflverse_data <- function(x,...){
#' @export
#' @keywords internal
rbindlist_with_attrs <- function(dflist){

nflverse_timestamp <- attr(dflist[[length(dflist)]], "nflverse_timestamp")
nflverse_type <- attr(dflist[[length(dflist)]], "nflverse_type")
out <- data.table::rbindlist(dflist, use.names = TRUE, fill = TRUE)
Expand Down
1 change: 1 addition & 0 deletions R/utils_cran.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' limiting data.table CPU cores for examples/tests
#'
#' @export
#' @keywords internal
.for_cran <- function(){

cores <- min(
Expand Down
19 changes: 12 additions & 7 deletions R/utils_download_nflverse.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#' @param use_hive whether to create hive-style partition folders for each season, e.g. `"~/pbp/.season=2021/pbp.csv"`
#' @param .token a GitHub API token, `"default"` uses `gh::gh_token()`
#'
#' @examples {
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({
#' ## could also set options like
Expand All @@ -24,7 +25,6 @@
#' list.files(tempdir(),pattern = ".parquet$") # check that files were downloaded!
#' })
#' }
#' }
#' @export
nflverse_download <- function(...,
folder_path = getOption("nflreadr.download_path", default = "."),
Expand Down Expand Up @@ -115,21 +115,26 @@ nflverse_download <- function(...,
#'
#' @param .token a GitHub API token, `"default"` uses `gh::gh_token()`
#'
#' @return A dataframe containing release names, release descriptions, and
#' other relevant release information.
#' @export
#' @examples
#' \donttest{
#' \dontshow{
#' .for_cran()
#' # Change option for better output
#' old <- options(piggyback.verbose = FALSE)
#' }
#' \donttest{
#'
#' try( # avoids cran failures, can skip in normal usage
#' nflverse_releases()
#' )
#'
#' }
#' \dontshow{
#' # Restore old options
#' options(old)
#' }
#'
#' @return A dataframe containing release names, release descriptions, and
#' other relevant release information.
#' @export
nflverse_releases <- function(.token = "default") {
rlang::check_installed("piggyback (>= 0.1.2)", "gh")
if(.token == "default") .token <- gh::gh_token()
Expand Down
1 change: 1 addition & 0 deletions R/utils_gameid.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @export
#'
#' @examples
#' \dontshow{.for_cran()}
#' nflverse_game_id(2022, 2, "LAC", "KC")
nflverse_game_id <- function(season,
week,
Expand Down
2 changes: 1 addition & 1 deletion R/utils_join_coalesce.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#'
#'
#' @examples
#'
#' \dontshow{.for_cran()}
#' x <- data.frame(id1 = c(NA_character_,letters[1:4]), a = c(1,NA,3,NA,5), b = 1:5 * 10)
#' y <- data.frame(id2 = c(letters[3:11],NA_character_), a = -(1:10), c = 1:10 * 100)
#'
Expand Down
22 changes: 11 additions & 11 deletions R/utils_name_cleaning.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' with `NA` (depending on the value of `keep_non_matches`).
#' @export
#' @examples
#' \dontshow{.for_cran()}
#' x <- c("PIE", "LAR", "PIT", "CRD", "OAK", "SL")
#' # use current location and keep non matches
#' clean_team_abbrs(x)
Expand Down Expand Up @@ -60,7 +61,7 @@ clean_team_abbrs <- function(abbr, current_location = TRUE, keep_non_matches = T
#' @return a character vector of cleaned names
#'
#' @examples
#'
#' \dontshow{.for_cran()}
#' clean_player_names(c("A.J. Green", "Odell Beckham Jr. ", "Le'Veon Bell Sr."))
#'
#' clean_player_names(c("Trubisky, Mitch", "Atwell, Chatarius", "Elliott, Zeke", "Elijah Moore"),
Expand Down Expand Up @@ -117,22 +118,21 @@ clean_player_names <- function(player_name,
#' @param invert a character vector of columns that gets inverted when referring to the away team (e.g. home spread = 1 gets converted to away_spread = -1)
#'
#' @examples
#' \donttest{
#' \dontshow{.for_cran()}
#' # a small example dataframe
#' s <- data.frame(
#' game_id = c("2020_20_TB_GB", "2020_20_BUF_KC", "2020_21_KC_TB"),
#' game_type = c("CON", "CON", "SB"),
#' away_team = c("TB", "BUF", "KC"),
#' away_score = c(31L, 24L, 9L),
#' home_team = c("GB", "KC", "TB"),
#' home_score = c(26L, 38L, 31L),
#' location = c("Home", "Home", "Neutral"),
#' result = c(-5L, 14L, 22L),
#' game_id = c("2020_20_TB_GB", "2020_20_BUF_KC", "2020_21_KC_TB"),
#' game_type = c("CON", "CON", "SB"),
#' away_team = c("TB", "BUF", "KC"),
#' away_score = c(31L, 24L, 9L),
#' home_team = c("GB", "KC", "TB"),
#' home_score = c(26L, 38L, 31L),
#' location = c("Home", "Home", "Neutral"),
#' result = c(-5L, 14L, 22L),
#' spread_line = c(3, 3, -3)
#' )
#'
#' clean_homeaway(s, invert = c("result","spread_line"))
#' }
#' @return a dataframe with one row per team (twice as long as the input dataframe)
#' @export
clean_homeaway <- function(dataframe, invert = NULL){
Expand Down
2 changes: 1 addition & 1 deletion R/utils_progressively.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @param p a function such as one created by `progressr::progressor()` - also accepts purrr-style lambda functions.
#'
#' @examples
#'
#' \dontshow{.for_cran()}
#' \donttest{
#' try({ # prevents cran errors
#'
Expand Down
1 change: 1 addition & 0 deletions R/utils_sitrep.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#' @param redact_path a logical indicating whether options that contain "path"
#' in the name should be redacted, default = TRUE
#' @examples
#' \dontshow{.for_cran()}
#' \donttest{
#' try({
#' nflverse_sitrep()
Expand Down
19 changes: 9 additions & 10 deletions man/clean_homeaway.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 51acee7

Please sign in to comment.