Dave Dave -4 years ago 91
R Question

cor shows only NA or 1 for correlations - Why?

I'm running

on a
with all numeric values and I'm getting this as the result:

price exprice...
price 1 NA
exprice NA 1

So it's either
for each value in the resulting table. Why are the
s showing up instead of valid correlations?

Answer Source

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

We 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.

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download