cor shows only NA or 1 for correlations - Why?

后端 未结 6 1240
别那么骄傲
别那么骄傲 2020-12-08 07:03

I\'m running cor() on a data.framewith all numeric values and I\'m getting this as the result:

       price exprice...
price      1         


        
6条回答
  •  时光取名叫无心
    2020-12-08 07:26

    NAs also appear if there are attributes with zero variance (with all elements equal); see for instance:

    cor(cbind(a=runif(10),b=rep(1,10)))
    

    which returns:

       a  b
    a  1 NA
    b NA  1
    Warning message:
    In cor(cbind(a = runif(10), b = rep(1, 10))) :
      the standard deviation is zero
    

提交回复
热议问题