x <- 1:10
y <- c(5:1,6,10:7)
out1 <- cor.test(x,y,method="spearman")
out2 <- spearman.test(x,y)
# out1$p.value = 0.05169460
# out2$p.value = 0.05444507
# the correct p-value in this case is 0.05443067
c(out1$p.value, out2$p.value)
out2$p.value <- out1$p.value
# except of the p-value, the output is identical
identical(out1,out2)
# for negative correlation, there is no difference
out3 <- cor.test(x,-y,method="spearman")
out4 <- spearman.test(x,-y)
identical(out3,out4)
Run the code above in your browser using DataCamp Workspace