When someone is first starting out in R, if they are not used to programming, the various errors, warnings and messages that R provides can be intimidating. This is meant to be a useful collection of observed types of messages that R provides, along with an explanation of what R is trying to tell them.
If you have an error message you need help with file an issue.
If you have an error message and explanation you want to add, please clone the repo, add your message, and create a pull request.
You don’t need to do ‘install.packages(“tidyverse”)’ every time. Install is installing it on your system. You only need to do it again if you re-install R, or want a newer version. ‘library()’ loads it for use, and ‘install.packages()’ installs it to your computer.
instal.packages("tidyverse")
Error in instal.packages("tidyverse") :
could not find function "instal.packages
This error is telling you it can’t find the function. Most times, this is because it is spelled wrong, as it is here. Other times, it’s because you haven’t done “library(‘tidyverse’)” yet and it can’t find the function you want. This is a good reason to use a tab-completion enabled editor such as RStudio, it will help you make sure the spelling of functions is correct.
library("tidyverse")
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
::filter() masks stats::filter()
x dplyr::lag() masks stats::lag() x dplyr
This is telling you that there are packages you have loaded via ‘library(“tidyverse”)’ that have functions that are named the same as functions in the base install that are always loaded.
ggplot(...)
in ggplot() : could not find function "ggplot" Error
This is telling you that you have not loaded the library that the ggplot function is in (ggplot2 in this case). To fix this you load ggplot2 first with library(ggplot2)
.
= rnorm(100)
x = rnorm(1000)
y plot(x,y)
in xy.coords(x, y, xlabel, ylabel, log) :
Error 'x' and 'y' lengths differ
This is pretty clear, the number of x coordinates is different to the number of y coordinates you have given. Often caused by either a typo in x or y names, or you subsetted one and not the other. You can double check it by doing:
1:2)*(1:3)
(1] 1 4 3
[:
Warning messageIn (1:2) * (1:3) :
longer object length is not a multiple of shorter object length
This is only a warning, but you should usually think of it as an error. Your code is trying to do an operation on two vectors of different lengths. R has rules that allow the operation to proceed (which is why it’s only a warning) but you probably used the wrong name or subsetted one and not the other, or something similar.
2]
df[in df[2] : object of type 'closure' is not subsettable Error
Technically, R is telling you that you are trying to subset a function (df
is the density function for the F distribution). In practice, this almost always happens when you think you have a variable called df
(eg, a data frame) but R can’t find it. Most likely the variable doesn’t exist, but it might exist somewhere that R can’t see.
zip(zipfile, ...)
: 1: : Permission denied
sh:
Warning messagesystem2(zip, args, input = input) : error in running command In
As of R 4.0.3, this means that R can’t find the zip command on a Unix or Linux type system. The way to fix it is to do:
Sys.setenv(R_ZIPCMD = "path/to/zip")
If you have an error message you need help with file an issue. If you have an error message and explanation you want to add, please clone the repo, add your message, and create a pull request.
This project has a Contributor Code of Conduct, and you are asked to abide by it.