(Builds on: Getting help, Code style)
When you get stuck, first try and solve the problem yourself. A really powerful tool to do this is to pretend you are asking help from someone else. Start by clearly defining the problem, trying to find the smallest snippet of code that illustrates the problem. This is called a minimal reproducible example, or reprex for short. Often creating the reprex leads you to the solution because it forces you to carefully work through each step. Even if it doesn’t resolve the problem, you’re now in a better place to ask for help from another human.
To create reprexes we strongly recommend using the reprex package. It’s not available on CRAN yet, but you can install it from GitHub by running this code:
install.packages("devtools")
devtools::install_github("jennybc/reprex")