8.2 Reprex

  • If your googling doesn’t find anything useful, it’s a really good idea to prepare a reprex, short for minimal reproducible example.

  • A good reprex makes it easier for other people to help you, and often you’ll figure out the problem yourself in the course of making it.

  • There are two parts to creating a reprex:

    • Make your code reproducible: Capture everything, i.e. include any library() calls and create all necessary objects.
    • Make your code minimal. Strip away everything that is not directly related to your problem by creating a much smaller and simpler R object than the one you’re facing in real life or even using built-in data.
  • Creating a reprex may sound like a lot of work, but it has a great payoff:

    • Creating an excellent reprex often reveals the source of your problem and may allow you to answer your own question.

    • You’ll capture the essence of your problem in a way that is easy for others to play with which improves your chances of getting help.

  • The easiest way to avoid the mistake of accidentally miss something problem when creating a reprex by hand is by using the reprex package.