You can re-export nflreadr functions in your package by using the following roxygen template:
#' @inherit nflreadr::load_nextgen_stats
#' @export
# Need to add own examples if the function name is different
#' @examples
#' load_ng_stats(2020)
load_ng_stats <- nflreadr::load_nextgen_statsThe from_url family of functions are designed to be compatible with using progressr updates. Here’s an example, adapted from the load_rosters() source code:
load_rosters <- function(seasons = 1999:2020){
# Create a progressor function inside your function that knows how many "steps" there will be
p <- progressr::progressor(steps = length(seasons))
# Form the URLs to pass into rds_from_url
urls <- paste0(
"https://github.com/nflverse/nflfastR-roster/raw/master/data/seasons/roster_",
seasons, ".rds")
# Pass the progressor to the "p" argument of rds_from_url in a loop or map
out <- purrr::map_dfr(urls, rds_from_url, p = p)
return(out)
}This will cause p() to execute once for each rds_from_url call, effectively “signalling” progress.
In order to receive progress updates, the user must wrap the function (load_rosters, in this case) with progressr::with_progress() as shown here:
progressr::with_progress(load_rosters(2010:2020))For more information, please see the progressr documentation.