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 |
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 |
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: