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)
<- nflreadr::load_nextgen_stats load_ng_stats
The from_url
family of functions can be adapted with the
progressively()
function decorator to signal progress.
Here’s an example, adapted from the load_rosters()
source
code:
<- function(seasons = 1999:2020){
load_rosters
# Create a progressor function inside your function that knows how many "steps" there will be
<- progressr::progressor(steps = length(seasons))
p
# Form the URLs to pass into rds_from_url
<- paste0(
urls "https://github.com/nflverse/nflfastR-roster/raw/master/data/seasons/roster_",
".rds")
seasons,
# Use `progressively()` to wrap the existing function rds_from_url and
# call the `p()` progressor function as a signal immediately after each iteration
<- purrr::map_dfr(urls, progressively(rds_from_url,p))
out
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:
::with_progress(load_rosters(2010:2020)) progressr
For more information, please see the progressr documentation.