a <- c(1:10)
b <- c(1:10)
cor.test(a, b, method = "spearman", alternative = "greater", exact = TRUE)
Spearman's rank correlation rho
data: a and b
S = 0, p-value < 2.2e-16
alternative hypothesis: true rho is greater than 0
sample estimates:
rho
1
[1] 2.755732e-07
Since we have perfect rank correlation and only one permutation out of 10! could
give this for N = 10, the p-value should be 1/10!. Reading the code in prho.c,
it appears that the "exact" calculation uses the Edgeworth approximation for N >
9. This makes sense because, for similar examples with N <= 9, the results are
as expected (1 / N!).