stow_gh_release {dpkg} | R Documentation |
download a github release asset to the stow
R user directory
Description
Use stow to abstract away the process of downloading a file or a GitHub release asset to a user's data directory, only downloading files that have not already been downloaded.
Usage
stow_gh_release(owner, repo, dpkg, overwrite = FALSE)
stow(uri, overwrite = FALSE)
stow_url(url, overwrite = FALSE)
Arguments
owner |
string of repo owner |
repo |
string of repo name |
dpkg |
string of gh release tag (will be the same as the filename without the |
overwrite |
logical; re-download the remote file even though a local file with the same name exists? |
uri |
character string universal resource identifier; currently, must begin
with |
url |
a URL string starting with |
Details
Supported URI prefixes include:
-
https://
,http://
: download from a file -
gh://
: download a github release asset, formatted asgh://owner/repo/name
Stow downloads files to the users data directory; see ?tools::R_user_dir
.
Specify an alternative download location by setting the R_USER_DATA_DIR
environment variable.
The stow cache works by name only; that is, if a file with the same URI
has already been downloaded once, it will not be re-downloaded again
(unless overwrite = TRUE
).
Value
path to the stowed file or url to github release
Examples
Sys.setenv(R_USER_DATA_DIR = tempfile("stow"))
# get by using URL
stow("https://github.com/geomarker-io/appc/releases/download/v0.1.0/nei_2020.rds",
overwrite = TRUE) |>
readRDS()
# will be faster (even in later R sessions) next time
stow("https://github.com/geomarker-io/appc/releases/download/v0.1.0/nei_2020.rds") |>
readRDS()
# get a data package from a GitHub release
stow("gh://cole-brokamp/dpkg/mtcars-v0.0.0.9000", overwrite = TRUE) |>
arrow::read_parquet()
stow("gh://cole-brokamp/dpkg/mtcars-v0.0.0.9000") |>
arrow::read_parquet()