by Suf | May 7, 2022 | Programming, R, Tips
This error occurs when you try to specify the fill colours when using ggplot2, but the number of colours is not 1 or different from the total number of plots to fill. To solve this error you can either specify one fill colour argument or ensure the total number of...
by Suf | May 7, 2022 | Programming, R, Tips
This error occurs when trying to fit a linear regression model in R using the lm() function but either the predictor or response variables contain Not a Number (NaN) or infinity (Inf) values. You can solve this error by replacing the NaN and Inf values with NA values,...
by Suf | May 7, 2022 | Programming, R, Tips
If you are using the ggplot2 package to visualize data and forget to use a plus sign in the code, you will encounter the error: cannot add ggproto plots together. This tutorial will go through how to solve the error with code examples. Table of...
by Suf | May 7, 2022 | Programming, R, Tips
This error occurs if you put the else statement on a new line after an if statement. R interprets the if statement as complete and does not expect an else. You can solve this error by enclosing the entire if/else statement in braces/curly brackets {} or put the else...
by Suf | May 6, 2022 | Programming, R, Tips
If you try to use the predict() function and the column names in the test data frame do not match those in the data frame used to fit the model, you will raise the error in eval(predvars, data, env): object ‘x’ not found. The ‘x’ will be the...
by Suf | May 6, 2022 | Programming, R, Tips
If you try to perform an arithmetic operation and one or both of the operands are non-numeric, you will raise the error: non-numeric argument to binary operator. This error typically occurs when one of the operands is of character type. To solve this error, you can...