This is actually a warning message and also not an error message, yet it would still be annoying if it comes up while you are creating an important routine. The “Argument is not numeric or logical: returning na” message offers a reasonably easy to understand also description of the trouble. It occurs while you are utilizing the mean() feature and also it is an issue with the data form you are utilizing.

You are watching: Argument is not numeric or logical: returning na

## The circumstances of this problem.

This problem occurs once using the mean() function. This feature takes the mean value, which is a kind of average, of the worths in a vector used in the function.
> a = c(1,2,3,4,5)> b = c(TRUE,FALSE,TRUE,TRUE,FALSE)> c = c(“a”,”b”,”c”,”d”,”e”)> mean(c)<1> NAWarning message:In suppose.default(c) : discussion is not numeric or logical: returning NAThis instance produces a warning message bereason the vector “c” has personalities and not numeric or logical values. This is why this message is straightforward to understand. It specifically shows that the discussion demands to be either a numeric or logical worth.

This problem results from entering neither a numeric nor logical argument into the mean() function. In the example above, it is a vector of personalities yet it can happen anytime a vector contains a worth that is neither numeric or logical.
In this instance, the vector “a” has numeric worths. The expect worth below is 3 bereason the values in “a” are 1-5. Because these values are numeric, tright here is no message.> a = c(1,2,3,4,5)> b = c(TRUE,FALSE,TRUE,TRUE,FALSE)> c = c(“a”,”b”,”c”,”d”,”e”)> mean(b)<1> 0.6Here “b” which has logical worths of “TRUE” and “FALSE” causing an acceptable discussion. You gain a mean of 0.6, this is because the mean() function sees “TRUE” and “FALSE” as numeric worths of 1 and 0 respectively.

## How to deal with this error.See more: Pin On Jesus Calling April 1, Devotionals Daily: A Year With Jesus

If you have finish manage over the information, one solution is to make certain that the vector you are using in the mean() attribute contains just numeric or logical values. In such situations, this might mean manually rerelocating bad worths.Otherwise, you will want to use some form a filter to uncover and also remove any kind of unwanted values. The suggest, in either case, is to eliminate any worths that you do not want to apply to the mean() feature. The vital to this problem is to encertain that you are only utilizing numeric or logical values in the mean() feature.