You can re-export nflreadr
functions in your package by
using the following roxygen template:
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:
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/nflverse-rosters/",
"raw/master/data/seasons/roster_",
seasons,
".rds")
# Use `progressively()` to wrap the existing function rds_from_url and
# call the `p()` progressor function as a signal immediately after each iteration
out <- purrr::map_dfr(urls, progressively(rds_from_url,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:
For more information, please see the progressr documentation.