class: center, middle, inverse, title-slide .title[ # Reproducible examples and Git ] .author[ ### INFO 5940
Cornell University ] --- class: middle <img src="https://media.giphy.com/media/uRb2p09vY8lEs/giphy.gif" width="80%" style="display: block; margin: auto;" /> --- <img src="../../../../../../../../img/reprex.png" title="A side-by-side comparison of a monster providing problematic code to tech support when it is on a bunch of crumpled, disorganized papers, with both monsters looking sad and very stressed (left), compared to victorious looking monsters celebrating when code is provided in a nice box with a bow labeled 'reprex'. Title text reads 'reprex: make reproducible examples. Help them help everyone!'" alt="A side-by-side comparison of a monster providing problematic code to tech support when it is on a bunch of crumpled, disorganized papers, with both monsters looking sad and very stressed (left), compared to victorious looking monsters celebrating when code is provided in a nice box with a bow labeled 'reprex'. Title text reads 'reprex: make reproducible examples. Help them help everyone!'" width="80%" style="display: block; margin: auto;" /> .footnote[Source: [Allison Horst](https://github.com/allisonhorst/stats-illustrations)] --- ## 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/)]