Making reproducible R examples
When reporting issues with R software, it is very helpful to provide reproducible code examples. This means that the code is complete and self-contained, and that the results are provided along with the code.
If you provide reproducible examples, you will be relieving the developers of the need to contact you to get additional data files, to see the full output of your code, and so forth. This usually leads to a faster resolution to the issue at hand, with less effort for both you and the developers.
The reprex
package1 makes it trivial to create reproducible examples in R,
in three simple steps.
- Use your mouse (or some other scheme) to copy sample code onto your computer’s clipboard.
- In R, type
reprex::reprex()
to run your code and place it along with its output on the clipboard. - On a bug-reporting site2, do a “paste” operation to put the clipboard contents into an issue comment.
It’s as simple as that.
Footnotes
-
If
reprex
is not already installed, typeinstall.packages("reprex)
to install it. Once it’s installed, you will not need to install it again. ↩ -
For example, the oce issue-reporting site is https://github.com/dankelley/oce/issues ↩