Troubleshooting Errors and Warnings
We frequently run into error messages and warnings in these workshops! No need to fret this happens to the best R
users all the time. It may be helpful to go over them quickly.
Errors: These are things that will legitmately not make your code run whether these are misspelled object names, missing commas, unmatched parenthesis, etc…
Warnings: These just mean your code will run but there are some caveats attached like
ggplot
dropping missing observations or missing values are introduced by coercing to a vector to a numeric type.1
Common Errors2
File does not exist, or No such file or directory
This generally means one of two things. You misspelled the filename or you forgot to tell R where to look. To fix it you should check a few things
- Check to make sure that the name of the file is spelled correctly
- Check to make sure that your working directory is set correctly
- If the file is living in a folder in the working directory specify that folder with the correct slash
- This is probably the most common ones
- If the file is open in Excel close it. Sometimes Excel will hold things hostage so that could be your issue.
Could Not find function “functionineedtouse”
This is just R saying that it does not know what you are trying to do to the object because it can’t figure what the function is.
- Is the function spelled correctly(my most common mistake)
- If so did you run library(packagewithfunctionname)
- Do you need to install the package that function is living in?
Object Not found
If you get this error than this is R telling you that you are trying to reference an object that does not exist.
- Make sure the object name is spelled right
- Make sure that you have in fact assigned the said object
- Did you do something with all the neccessary R code, but forgot to assign it before running the code in question?
Column Does Not Exist
If you get his error than this means you are trying to reference a column that does not exist.
- Is the name of the variable spelled correctly?
- This can also include white space which requires you to use
Name of Var
- This can also include white space which requires you to use
- Make sure you are referencing the right object
- i.e. Did you create a new variable and assign it to a different object?
- When referencing the column did you drop it along the way?
Footnotes
Both examples are derived from Statistical Inference via Data Science: A ModernDive into R and the Tidyverse↩︎
These are the ones I tend to run into and the coverage and advice is from Nick Huntington-Klein’s post↩︎