Skip to content

Commit

Permalink
accept file_type arg for ftn data
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Oct 11, 2023
1 parent a1e8822 commit 126d168
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: nflreadr
Title: Download 'nflverse' Data
Version: 1.4.0.08
Version: 1.4.0.09
Authors@R: c(
person("Tan", "Ho", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-8388-5155")),
Expand Down
9 changes: 7 additions & 2 deletions R/load_ftn_charting.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#'
#' @param seasons a numeric vector of seasons to return, defaults to most recent season.
#' If set to `TRUE`, returns all available data. Data available from 2022 onwards.
#' @param file_type One of `c("rds", "qs", "csv", "parquet")`. Can also be set globally with
#' `options(nflreadr.prefer)`
#'
#' @author FTN Data
#' @source FTNData.com
Expand All @@ -27,15 +29,18 @@
#' @family ftn_charting
#'
#' @export
load_ftn_charting <- function(seasons = most_recent_season()){
load_ftn_charting <- function(seasons = most_recent_season(),
file_type = getOption("nflreadr.prefer", default = "rds")){

if(isTRUE(seasons)) seasons <- 2022:most_recent_season()

stopifnot(is.numeric(seasons),
seasons >= 2022,
seasons <= most_recent_season())

urls <- glue::glue("https://github.com/nflverse/nflverse-data/releases/download/ftn_charting/ftn_charting_{seasons}.rds")
file_type <- rlang::arg_match0(file_type, c("rds", "csv", "parquet", "qs"))

urls <- glue::glue("https://github.com/nflverse/nflverse-data/releases/download/ftn_charting/ftn_charting_{seasons}.{file_type}")

out <- load_from_url(
urls,
Expand Down
8 changes: 7 additions & 1 deletion man/load_ftn_charting.Rd

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

0 comments on commit 126d168

Please sign in to comment.