cor shows only NA or 1 for correlations - Why?

后端 未结 6 1241
别那么骄傲
别那么骄傲 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:25

    The 1s are because everything is perfectly correlated with itself, and the NAs are because there are NAs in your variables.

    You will have to specify how you want R to compute the correlation when there are missing values, because the default is to only compute a coefficient with complete information.

    You can change this behavior with the use argument to cor, see ?cor for details.

提交回复
热议问题