What is a reprex and why is it useful?


  • Mentors and helpers usually need to run your code in order to help debug it.
  • Minimal reproducible examples make it possible for helpers to run your code, which lets them “feel your pain” and figure out what’s wrong.
  • Making a minimal reproducible example helps you understand your own problem and often leads to finding the answer yourself!
  • You can use the {reprex} package to test whether your example is reproducible.

Identify the problem and make a plan


Minimal Reproducible Data


  • A minimal reproducible dataset contains (a) the minimum number of lines, variables, and categories, in the correct format, to reproduce a certain problem; and (b) it must be fully reproducible, meaning that someone else can reproduce the same problem using only the information provided.
  • You can create a dataset from scratch using as.data.frame, you can use available datasets like iris or you can use a subset of your own dataset
  • You can share your own data by first subsetting it into its minimal components and then using dput() to create it via reproducible code

Minimal Reproducible Code


Asking your question


  • The {reprex} package makes it easy to format and share your reproducible examples.
  • Following a certain set of steps will make your questions clearer and likelier to get answered.