Cheatsheets are great for refreshing your memory and finding new functions and plots to use.
Help > Cheatsheets >
ggplot’ing options.From your browser
From within R
Books
Searching online
r or rstats + the question[r] tagInside R
?arrange() or help(dplyr)Email us!
These are a few of the things we personally forget to do all the time and cause 90% of our errors. They’re good first checks if R starts throwing errors or behaving strangely.
( has a corresponding closing ).\ backward slashes like Windows, check that they didn’t sneak into your expression somewhere. When in doubt use the / forward slash.If you think you have completed typing your code, and instead of seeing the > command prompt at the console you see the + character instead. That’s a good sign that either R is still thinking very-very hard, or it is still waiting for you to complete your expression. You can hit Esc or Ctrl-C to force your way back to the console and try typing your code again.
R is very picking about spelling. So are meteorologists when talking about lighting storms.
ggplot we build up plots one piece at a time by adding expressions to one another with the + character. When doing this, make sure the + goes at the end of each line, and not the beginning.Put the + sign here to make ggplot happy:
ggplot(data = mpg, aes(x = displ, y = hwy)) +
geom_point()Put it on the next line to make ggplot sad:
ggplot(data = mpg, aes(x = displ, y = hwy))
+ geom_point()Not all error messages are helpful or easy to interpret, but they do seem to be getting better in many R packages. When googling an error message it can help to put the entire message in quotes. For the error below we would search for "Error in fit[5, 100, ] : subscript out of bounds".