zip-utils: Download and unpack a ZIP file

zip-utilsR Documentation

Download and unpack a ZIP file


Functions to download and unpack a ZIP file into a local folder of files, with very intentional default behaviour. Useful in pedagogical settings or anytime you need a large audience to download a set of files quickly and actually be able to find them. The underlying helpers are documented in use_course_details.


use_course(url, destdir = getOption("usethis.destdir"))

  destdir = getwd(),
  cleanup = if (rlang::is_interactive()) NA else FALSE



Link to a ZIP file containing the materials. To reduce the chance of typos in live settings, these shorter forms are accepted:

* GitHub repo spec: "OWNER/REPO". Equivalent to
* or shortlinks: "" or "".
  The instructor must then arrange for the shortlink to point to a valid
  download URL for the target ZIP file. The helper
  [create_download_url()] helps to create such URLs for GitHub, DropBox,
  and Google Drive.

Destination for the new folder. Defaults to the location stored in the global option usethis.destdir, if defined, or to the user's Desktop or similarly conspicuous place otherwise.


Whether to delete the original ZIP file after unpacking its contents. In an interactive setting, NA leads to a menu where user can approve the deletion (or decline).


Path to the new directory holding the unpacked ZIP file, invisibly.


  • use_course(): Designed with live workshops in mind. Includes intentional friction to highlight the download destination. Workflow:

    • User executes, e.g., use_course("").

    • User is asked to notice and confirm the location of the new folder. Specify destdir or configure the "usethis.destdir" option to prevent this.

    • User is asked if they'd like to delete the ZIP file.

    • If new folder contains an .Rproj file, a new instance of RStudio is launched. Otherwise, the folder is opened in the file manager, e.g. Finder or File Explorer.

  • use_zip(): More useful in day-to-day work. Downloads in current working directory, by default, and allows cleanup behaviour to be specified.


## Not run: 
# download the source of usethis from GitHub, behind a shortlink

# download the source of rematch2 package from CRAN

# download the source of rematch2 package from GitHub, 4 ways

## End(Not run)

usethis documentation built on July 9, 2023, 7:23 p.m.