Calculate Spearman's Rank Correlation Coefficient
- by Arvigeus
I'm trying to calculate correlations using this method.
However, when I do the math by hand, I get one result, and when I do it with R - cor(dt, use="complete.obs", method="spearman") - I get totally different thing.
Example data below:
---------------------------------
AnswerPosID.1007 AnswerPosID.1008
---------------------------------
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 2
1 2
1 1
1 1
1 1
1 1
2 1
2 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
---------------------------------
Manual result: 0.799777530589544;
R cor: -0.07142857