[R] Wrong result with cor(x, y, method="spearman", use="complete.obs") with NA's???

Karl Knoblick karlknoblich at yahoo.de
Mon Aug 30 11:52:03 CEST 2004


Is there an error in cor to calculate Spearman
correlation with cor if there are NA's? cor.test gives
the correct result. At least there is a difference.

Or am I doing something wrong???

Does anybody know something about this?

cor(a, b, method="spearman", use="complete.obs")
# -0.9819805
cor.test(a, b, method="spearman")
# -1

Without the NA both methods give -1
cor(a[1:3], b[1:3], method="s", use="c")
# -1

Is there another method to calculate a nice table with
correlations like cor(data.frame) is doing? Perhaps
even with p-values or "stars"?


More information about the R-help mailing list