Running:
cor(x, use = "pairwise.complete.obs")`
vs running
c <- cov(x, use = "pairwise.complete.obs")
cov2cor(c)
give different results. Anyone know why and which one gives correct results? Both functions call C++ code which I haven't figured out how to parse.
Reproducible data:
x <- data.frame(a1 = rnorm(10), a2 = rnorm(10), a3 = rnorm(10))
x$a1[c(1,3)] <- NA
c <- cov(x, use = "pairwise.complete.obs")
cov2cor(c)
cor(x, use = "pairwise.complete.obs")