Errors, warnings, and messages

One thing that intimidates new R and RStudio users is how it reports errors, warnings, and messages. R reports errors, warnings, and messages in a glaring red font, which makes it seem like it is scolding you. However, seeing red text in the console is not always bad.

R will show red text in the console pane in three different situations:

Remember, when you see red text in the console, don’t panic. It doesn’t necessarily mean anything is wrong. Rather:

red If the text starts with “Error”, figure out what’s causing it. Think of errors as a red traffic light: something is wrong!

yellow If the text starts with “Warning”, figure out if it’s something to worry about. For instance, if you get a warning about missing values in a scatterplot and you know there are missing values, you’re fine. If that’s surprising, look at your data and see what’s missing. Think of warnings as a yellow traffic light: everything is working fine, but watch out/pay attention.

green  Otherwise, the text is just a message. Read it, wave back at R, and thank it for talking to you. Think of messages as a green traffic light: everything is working fine and keep on going!

Attribution: This section is adapted from ModernDive by Chester Ismay and Albert Y. Kim

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.