class: center, middle, inverse, title-slide .title[ # Reproducible examples ] .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" alt="A side-by-side comparison of a monster providing problematic code to techsupport when it is on a bunch of crumpled, disorganized papers, with both monsterslooking sad and very stressed (left), compared to victorious looking monsterscelebrating when code is provided in a nice box with a bow labeled 'reprex'. Titletext 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