EVOLUTION-MANAGER
Edit File: zip-utils.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Download and unpack a ZIP file</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for zip-utils {usethis}"><tr><td>zip-utils {usethis}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Download and unpack a ZIP file</h2> <h3>Description</h3> <p>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 <a href="use_course_details.html">use_course_details</a>. </p> <h3>Usage</h3> <pre> use_course(url, destdir = getOption("usethis.destdir")) use_zip( url, destdir = getwd(), cleanup = if (rlang::is_interactive()) NA else FALSE ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>url</code></td> <td> <p>Link to a ZIP file containing the materials. To reduce the chance of typos in live settings, these shorter forms are accepted: </p> <div class="sourceCode"><pre>* GitHub repo spec: "OWNER/REPO". Equivalent to `https://github.com/OWNER/REPO/DEFAULT_BRANCH.zip`. * bit.ly or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz" or "rstd.io/foofy". 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. </pre></div></td></tr> <tr valign="top"><td><code>destdir</code></td> <td> <p>The new folder is stored here. If <code>NULL</code>, defaults to user's Desktop or some other conspicuous place. You can also set a default location using the option <code>usethis.destdir</code>, e.g. <code>options(usethis.destdir = "a/good/dir")</code>, perhaps saved to your <code>.Rprofile</code> with <code><a href="edit.html">edit_r_profile()</a></code></p> </td></tr> <tr valign="top"><td><code>cleanup</code></td> <td> <p>Whether to delete the original ZIP file after unpacking its contents. In an interactive setting, <code>NA</code> leads to a menu where user can approve the deletion (or decline).</p> </td></tr> </table> <h3>Value</h3> <p>Path to the new directory holding the unpacked ZIP file, invisibly. </p> <h3>Functions</h3> <ul> <li> <p><code>use_course</code>: Designed with live workshops in mind. Includes intentional friction to highlight the download destination. Workflow: </p> <ul> <li><p> User executes, e.g., <code>use_course("bit.ly/xxx-yyy-zzz")</code>. </p> </li> <li><p> User is asked to notice and confirm the location of the new folder. Specify <code>destdir</code> or configure the <code>"usethis.destdir"</code> option to prevent this. </p> </li> <li><p> User is asked if they'd like to delete the ZIP file. </p> </li> <li><p> If new folder contains an <code>.Rproj</code> file, a new instance of RStudio is launched. Otherwise, the folder is opened in the file manager, e.g. Finder or File Explorer. </p> </li></ul> </li> <li> <p><code>use_zip</code>: More useful in day-to-day work. Downloads in current working directory, by default, and allows <code>cleanup</code> behaviour to be specified. </p> </li></ul> <h3>Examples</h3> <pre> ## Not run: # download the source of usethis from GitHub, behind a bit.ly shortlink use_course("bit.ly/usethis-shortlink-example") use_course("http://bit.ly/usethis-shortlink-example") # download the source of rematch2 package from CRAN use_course("https://cran.r-project.org/bin/windows/contrib/3.4/rematch2_2.0.1.zip") # download the source of rematch2 package from GitHub, 4 ways use_course("r-lib/rematch2") use_course("https://api.github.com/repos/r-lib/rematch2/zipball/HEAD") use_course("https://api.github.com/repos/r-lib/rematch2/zipball/main") use_course("https://github.com/r-lib/rematch2/archive/main.zip") ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>usethis</em> version 2.1.6 <a href="00Index.html">Index</a>]</div> </body></html>