class: center, middle, inverse, title-slide .title[ # Reproducible examples and Git ] .author[ ### MACS 30500
University of Chicago ] --- class: middle <img src="https://media.giphy.com/media/uRb2p09vY8lEs/giphy.gif" width="80%" style="display: block; margin: auto;" /> --- class: center, middle <blockquote class="twitter-tweet"><p lang="en" dir="ltr">New favorite word smash: reprex, for {rep}roducible {ex}ample. Will use it everywhere, starting <a href="https://t.co/Wk4lqYQ6Oz">https://t.co/Wk4lqYQ6Oz</a> cc <a href="https://twitter.com/JennyBryan?ref_src=twsrc%5Etfw">@JennyBryan</a></p>— Romain François 👨👧👧 (@romain_francois) <a href="https://twitter.com/romain_francois/status/530011023743655936?ref_src=twsrc%5Etfw">November 5, 2014</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> --- ## Reproducible examples * reprex (noun) * `reprex` * `reprex::reprex()` --- ## Why reprexes? Easier to talk about code that: * Actually runs -- * I don't have to run -- * I can easily run --- ## `reprex` ```r library(tidyverse) count(diamonds, colour) ``` --- ## Customizing `reprex()` .panelset[ .panel[ .panel-name[Include session info] ```r reprex( x = mean(rnorm(100)), si = TRUE ) ``` ] .panel[ .panel-name[Change venue] ```r reprex( x = mean(rnorm(100)), venue = "r" ) ``` ] .panel[ .panel-name[Style the code] ```r reprex( x = { if (TRUE) "true branch" else { "else branch" } }, style = TRUE ) ``` ] ] --- ## Reprex do's and don'ts * Ensure the example is **fully** reproducible * Use the smallest, simplest, most built-in data possible * Include commands on a strict "need to run" basis * Consider including "session info" * Use good coding style to ensure the readability of your code by other human beings * Ensure portability of the code --- ## Build some reproducible examples <img src="https://media.giphy.com/media/l4Ki2obCyAQS5WhFe/giphy.gif" width="65%" style="display: block; margin: auto;" />
15
:
00
--- class: center, middle <img src="/img/git-meme.jpeg" width="80%" style="display: block; margin: auto;" /> --- ## Git ### What files to commit * Source files * Markdown files * Data files ### What files to not commit * Temporary files * Log files * Files with private details * Any file greater than 100 megabytes --- ## `.gitignore` * System file * Tells Git which files/directories to ignore --- ## Git LFS * [Git Large File Storage](https://git-lfs.github.com/) * Separate software for tracking large files * Integrates with Git * Generally charges a fee --- ## Accidentally cloned from the main <img src="https://media.giphy.com/media/3oxHQKW9lw6rK9kYtq/giphy.gif" width="80%" style="display: block; margin: auto;" /> --- ## Accidentally cloned from the main ```bash remote: Permission to cfss-su22/hw03.git denied to cfss-student fatal: unable to access 'https://github.com/cfss-su22/hw03.git/': The requested URL returned error: 403 ``` -- ```r usethis::use_git_remote( name = "origin", url = "<YOUR_FORK_URL>", overwrite = TRUE ) ``` --- ## Avoiding Git problems 1. Commit early and often 1. Push regularly to GitHub --- ## Burn it all down <img src="https://imgs.xkcd.com/comics/git.png" width="35%" style="display: block; margin: auto;" /> .footnote[Source: [xkcd](https://xkcd.com/1597/)]