Common R Error Messages

Because we all love the meticulously documented yet mildly inscrutable error messages that R occasionally throws, here are some notes on what they are talking about and how to deal with them.

Root Cause: improper method of looking at a single cell of that data type

Root Cause: R cannot find the file you’re trying to open. Generally an issue with how you are pointing to your working directory. Could also be a problem with an old / bad file reference hiding out in your environment from a past project or imported script. Reset with setwd().

Type conversion error between a list object and the as.numeric function which expects either a single element or a single vector of values. We explain how to solve this issue and why R threw the error in the first place.

Common variant on the first error on this list. You’re feeding a list to something that expects an atomic vector.

Usually a syntax error caused by omitting a critical operator (+, -, /, *) from a calculation and using brackets immediately afterwards. R parses that as function instead of bad syntax and takes it seriously enough that you wonder why it’s trying to execution functions that don’t exist.

This is a syntax error related to matching how you access a data element. Lists use $, atomic vendors use brackets to identify specific elements

Another “I can’t find it” error. Generally either related to typographical errors in declaring or calling a function or a missing library declaration. Occasionally caused by loading packages that contain the same function name into the same namespace. Sometimes can be even weirder…