While executing the code in R, it is very likely that we get some error. There are some common errors like syntax & missing packages. By following the below checklist you can quickly fix the code errors
Couldn’t find the object: Like for example, we named an object as “myvar” and we’ll be searching uppercase “myvar”, i.e., we are trying to refer something which is not existing.
myvar <- c(15, 17, 16, 15, 16) Myvar Error: object 'Myvar' not found
Most of the times we make mistake in upper case and lower case. We couldn’t find a specific function, we are writing a function but the function is not there or we might be referring the function in a wrong way. Maybe the relevant R packages are not installed, and then install the package which can be seen in the console.
qplot(mpg, wt, data=mtcars) Error: could not find function 'qplot' library(ggplot2) qplot(mpg, wt, data=mtcars)
Non-numeric arguments are like if we’re trying to do arithmetic or math on strings, then obviously error will occur.
Name<- c("John", "Bob", "Kevin", "Smith", "Rick") Name+1
Basically, if we’re doing incompatible operations, then we might get this type of error.
- No such file or directory.
- This package is incompatible with R and there are some packages which get updated, say package version 1 might be compatible with R version 3 but later on that package, it might have been upgraded or renamed. As we work on, we’ll get to know more about this.
We can just put a question mark (?) and type the function name for help (?str() ) or R help documentation is also good, rather than searching in the help library, we can directly search it in Google.
With this, the basic introduction to R has come to an end. We will be using these topics very often while working on R. In later sessions we will discuss Data handling techniques