# How to test using Spearman correlation in R?

#### John.Thomas

##### New Member
Given such data
X-Y
2-6
4-9
6- 3
8- 12
10- 15

When using pearson correlation it will be straight forward, however, when using spearman, should we arrange the data before running the test? Something like

X- Order X ** Y - Order Y
2-1 ** 6
4-2 ** 9
6- 3 ** 3
8- 4 ** 12
10- 5 ** 15

then we order according to Y
X- Order X ** Y - Order Y
6- 3 ** 3 - 1
2-1 ** 6 - 2
4-2 ** 9-3
8- 4 ** 12 - 4
10- 5 ** 15 - 5

Then we compare the ranks
Order X ** Order Y
3 ** 1
1 ** 2
2 ** 3
4 ** 4
5 ** 5