Applying some “code first aid” can help address problems in your
code.Add commentMore actions
Helpers can more easily debug your code if you provide them with a
small example of the problem (a “reprex”) that they can tinker with
themselves.
In the process of building a reprex, you may find the solution
yourself.
In the rest of this lesson, we will be working through a “road map”
to getting unstuck that includes code first aid and the process of
making a reprex.
The surveys dataset includes records of rodents
captured in a variety of experimental plots over a 12-year period,
including some data about each rodent’s sex and morphology.
A minimal reproducible dataset contains (a) the minimum number of
lines, variables, and categories, in the correct format, to replicate
your issue; and (b) it must be fully reproducible, meaning that someone
else can access or run the same code to reproduce the dataset needed for
your reprex.
To make it accessible, you can create a dataset from scratch using
as.data.frame, you can use an R dataset like
cars, or you can use a subset of your own dataset and then
use dput() to generate reproducible code.