Reproducible Examples with the reprex package
Reproducible Examples and the `reprex` package.
https://speakerdeck.com/jennybc/reprex-reproducible-examples-with-r
Jump to:
0:08 Intro
0:40 Basic usage of reprex
3:35 Motivation, why use reprex? "Help me help you"
4:08 Define `reprex`?
Three commons ways to use the term.
1. noun, a reproducible example
2. the reprex package. a tool to build R `reprex`s
3. reprex::reprex(), a function in `reprex` to make a reprex.
5:26 When should you use a reprex?
6:14 reprex installation and setup.
How do you actually get repex on your machine?
7:59 Advanced setup and discussion.
9:45 Please use advanced features responsibly.
11:02 Why does the reprex package exist?
Anyone who has helped teach R or dealt with github issues, twitter, stack overflow & RStudio community questions knows that helping people diagnose their coding problems can be hard.
This tool comes from hard-won experience. It’s aim to is help people ask well formed questions and increase the chances of getting well formed answers quickly.
12:52 philosophy behind reprex
1. code that I can run
2. code that I don't need to run
3. code that I can easily run
13:52 code that I can run.
17:25 Tips on writing good `reprex`s. Dos and don'ts.
18:52 How do I get my data into my reprex?
Getting small data and CSV type data into your reprex is easy.
“I have a big hairy data object and I can only show their problem by using it”, but that's not always the case.
21:02 code that I don't need to run
reprex gives your reader the code and reveals the output being produced by that code. For experienced coders, that might be enough to help you.
22:44 code that I can easily run
Don't copy and paste from the R console. This is usually annoying for your reader.
Worse than console copy-pasta is the screenshot. (Many people think screenshots of code are downright offensive.)
25:03 reprex_clean
If you copy someone else's reprex into your consolve, it may include their output, making your new reprex a untidy.
Here are tips for taking someone else's reprex code and output, and create a clean reprex reply.
25:54 shock and awe
More interesting features of the reprex package.
- 26:29 What about figures and plots in your reprex? So happy you asked about that. reprex will automatically upload your images to imgur.com.
- 28:23 Create a reprex by explicitly providing your code in the reprex call.
- 29:00 when you need your reprex to work in the current working directory.
- 30:45 Differently flavored markdown. Optimize your reprex markdown output for github, stack overflow, or the RStudio community.
- 30:31 Make your reprex create an R script, with your reprex outputs as comments. This is handy for pasting into an email or slack-type-app.
- 32:25 Rich text format, rtf output. (currently experimental feature as of this video)
- 33:06 supress the reprex add at the bottom of your reprex
- 33:19 Include session info.
- 33:54 Auto styling of your code. Good if you're dealing with poorly formatting code.
- 34:25 Change your comments string.
- 34:32 Silence Tidyverse startup messages.
- 35:00 Capture a reprex that sends messages to standard output and standard input (e.g. package installation compilation messages).
36:13 Set up personal defaults for your reprex usage.
36:54 reprex RStudio addins; render reprex and reprex selection. These accelerate your use of reprex.
39:01 The human side of reproducible examples.
How to ask questions in ways that are most likely to get answered.
Sorry for the tough love, but this is important. Why are you always asked to give a reprex?
- Experts try to use reproducible examples to ensure their advice works.
- Making a good reprex is hard. But, you are asking them to solve a problem for you, so meet them halfway.
- Creating reprexes is good coding practice.
- Making a good reprex is often a good way to debug your issue in the embarrassment-free privacy of your own home.
- reprexes lead to discussions more likely to help people in the future.
44:34 Behind the scenes of reprex
44:44 Thanks for those that helped make reprex possible.
Questions and Answers
- 46:05 can reprex capture variables and objects in the current environment? (not yet, maybe in development)
- 47:25 does reprex actually check that the code is self contained? (self contained)
- 48:08 does readr::read_csv support the text argument? (yep, just read the help manual for readr)
readr
reprex
rstudio
tidyverse
Reprex
Reproducible Examples
R-Coding
R-Software
R-Stats
Statistics
Coding
Data Science