Sometimes code you write doesn’t work. That’s OK, it happens to everyone.
Here are a few pointers on how to get things working.
If you get an error message, read what the message says. Sometimes that is all it takes.
Read the whole message: sometimes the most important part is at the beginning.
If the message doesn’t makes sense to you, try Google: often someone else has asked about the same issue and received a useful answer.
Simplify your code.
Finding your bug usually involves double checking all the things you are sure you did right until you find the one you didn’t.
If you can’t resolve things yourself you may need to ask for help.
When you ask for help, it is best to reduce your problem to a simple, reproducible example (reprex
): The smallest set of expressions you can create that will show the problem starting with a fresh R session.
In the process of creating a reprex
you may figure out what is wrong.
If you don’t find your problem in putting together a reprex
, you have something you can post on the Q&A discussion board that someone else can look at and try out.
To make it easier to someone to try out your reprex, it is important to post it as text that someone can copy and paste into their R session, not as a screen shot.
Some References:
reprex
package.