This tutorial illustrates how to deal with the error message “non-numeric argument to binary operator” in the R programming language.

You are watching: R non-numeric argument to binary operator

Please note that this page illustrates the error message returned by Base R. In case you are looking for the error message “Error in max.item – min.item : non-numeric argument to binary operator” returned by the alpha function of the psych package, you may have a look here.

Table of contents:


Let’s dive right into the example!

Example: Reproducing & Fixing the Error Message: non-numeric argument to binary operator

In this Example, I’ll explain how to reproduce and fix the error message “non-numeric argument to binary operator”. First, let’s create an example that reproduces the error:


5 * "three" # Trying to use character string in equation# Error in 5 * "three" : non-numeric argument to binary operator

5 * "three" # Trying to use character string in equation# Error in 5 * "three" : non-numeric argument to binary operator


As you can see based on the previous R code, we have tried to use a character string in an equation (i.e. “three”). Unfortunately, this is not possible in the R programming language.

If we want to solve this problem, we need to replace the character string by a numeric value (i.e. 3). Let’s do that:


As you can see, the RStudio console is not returning the error anymore. Instead it shows the result of our equation.

Video & Further Resources

Would you like to learn more about error messages in R? Then you might have a look at the following video of my YouTube channel. I explain the R programming code of this page in the video instruction:

The YouTube video will be added soon.

Besides the video, you could have a look at the other articles of my website.

Summary: In this article you learned how to handle the error non-numeric argument to binary operator in the R programming language. Tell me about it in the comments, in case you have additional questions.

See more: How To Get To The Cathedral Of The Deep ? Dark Souls 3 Cathedral Of The Deep Walkthrough


Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.I hate spam & you may opt out anytime: Privacy Policy.


2.1 / 5 ( 17 votes )
6 Comments. Leave new
*

Hubermane
June 20, 2021 4:09 pm

In need help for a test cromcah’s alpha: Error:non-numeric argument to binary operator, how I can resolve it?


Reply
*

Tidy
June 22, 2021 6:07 am

Hi Joachim, I’m in the same boat as Hubermane. I’ve used this syntax with other measures and haven’t run into the same issue. My code: