19  Common Error Messages

19.0.1 Function not found

  • Check the spelling and capitalization.
  • Did you load the package in your first code chunk?

19.0.2 Object not found

R can’t find the object you are referring to. Here are some debugging steps:

  • Check the spelling and capitalization.
  • If you are referring to a variable inside a data set, did you use $ notation?
  • Can you find this variable in some other manner? (i.e. )
  • If this piece of code works when you are working interactively, but not when you knit, then check where you created this variable. Is it written either in this current code file or your data management file?
  • Did you create this variable in your data management file, and then forget to run the entire code document (hence recreating the analysis data set with this new variable)
  • Shut down and restart R studio entirely.

19.0.3 Object of length 0

This object does not exist, or is empty. Check how you created this object initially.

19.0.4 Discrete scale applied to continuous object

Read that error message carefully. It explains exactly what the problem is. It is up to you to problem solve to figure out which variable you are trying to apply a scale to (like color or fill), what it’s data type is.

19.0.5 Package inputenc error: Unicode char not set up for use with

When you want to use certain symbols in math notation, such as Greek letters or the tilde (\(\sim\)), it is important that you type in the commands for them (e.g., to write \(\sim\), type or for the Greek letter \(\mu\), type ). If you get this error message, there are a couple of possibilities. Either you omitted a around the notation, or you copied and pasted symbols straight from the course notes. In the latter case, find the symbol and replace it with its command (these are usually pretty self-explanatory but when in doubt, Google it).

19.0.6 Continuous x aesthetic – did you forget aes(group=…)?

This ggplot2 error message will show up when the aesthetics of a plot don’t map to the geometry of your data. Try either of these solutions depending on your variable type:

  • Change your x variable to a discrete data type, such as a factor.
  • Add the argument group=1 to the aesthetics of the plot, aes().