How to interpret Spearman correlation in R when it's different from Excel

I've been running some correlations in R and in Excel, and since I'm getting very different results on the same data I'm very confused as to what is actually correct. I want to run the correlation on larger data in R, so the excel analysis was just to get some idea of what to expect, but now I don't trust myself with R on this.

Here is the data and results

X  Y
1  166
2  197
3  172
5  169
6  173
6  237
7  389
8  232
8  208

cor.test(X, Y, method="spearman")

S = 34.283, p-value = 0.03062
alternative hypothesis: true rho is not equal to 0
sample estimates:
      rho 
0.7143109 

But according to excel (using "correl"), the correlation between these is around 0.48. Is that supposed to correspond to the S or the rho, or something else that I'm missing?


Solution 1:

tl;dr it looks like Excel is giving you the Pearson correlation, not the Spearman correlation. (This is in fact exactly what the help page you linked is saying, although it never uses the word "Pearson". How did you conclude that method = "spearman" was the right match for what Excel was computing ... ?)

cor.test(d$X,d$Y) (I saved the data frame as d) gives

    Pearson's product-moment correlation

data:  d$X and d$Y
t = 1.4448, df = 7, p-value = 0.1918
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2711667  0.8673254
sample estimates:
      cor 
0.4792647