Warning Message in R – cor() standard deviation is zero (2 Examples)

In this R tutorial you’ll learn how to deal with the “warning message in cor(X) : the standard deviation is zero”.

Example 1: Replicating the Warning Message in cor(X) : the standard deviation is zero

cor(x = c(1, 1, 1),        # All values in x are equal
    y = 1:3)
# [1] NA
# Warning message:
# In cor(x = c(1, 1, 1), y = 1:3) : the standard deviation is zero

Example 2: Solving the Warning Message in cor(X) : the standard deviation is zero

cor(x = c(1, 1, 2),        # Different values in x
    y = 1:3)
# [1] 0.8660254

Related Tutorials & Further Resources

In addition, you might have a look at the related articles on this homepage:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top