FAQ: What's a reproducible example (`reprex`) and how do I create one?

Why reprex?

Getting unstuck is hard. Your first step here is usually to create a reprex, or reproducible example. The goal of a reprex is to package your code, and information about your problem so that others can run it and feel your pain. Then, hopefully, folks can more easily provide a solution.

What's in a Reproducible Example?

Parts of a reproducible example:

  1. background information - Describe what you are trying to do. What have you already done?
  2. complete set up - include any library() calls and data to reproduce your issue.
    data for a reprex: Here's a discussion on setting up data for a reprex
  3. make it run - include the minimal code required to reproduce your error on the data provided.
    People should be able to copy and paste your code chunk and get the same error.
    How do I format my text so it has nice code chunks?
  4. minimal - strip away everything that is not directly related to your problem. This usually involves creating a much smaller and simpler set of code and data compared to that which created your issue.

Use the reprex-package to Build Your Reproducible Example

When creating a reprex by hand, it’s easy to accidentally miss something that means your code can’t be run on someone else’s computer. Avoid this problem by using the reprex-package.
The reprex package will save effort for you and others who want to help.

Personal and Private Information

Users should not share personal or protected information in topic threads or reprex data.
What if you need to share contact info or an ip, or discuss data for a reprex related to a protected dataset? What if you see a violation of this policy? Check out Personally Identifiable & Protected Information Guide guide and our Privacy Policy


Beginners - Step by Step Help

Help asking R-related questions (not specific to the reprex-package)

Background on the reprex-package

7 Likes