# 25.3: Robust Correlations (24.3.2)

- Page ID
- 8849

In the previous chapter we also saw that the hate crime data contained one substantial outlier, which appeared to drive the significant correlation. To compute the Spearman correlation, we first need to convert the data into their ranks, which we can do using the `order()`

function:

```
hateCrimes <- hateCrimes %>%
mutate(hatecrimes_rank = order(avg_hatecrimes_per_100k_fbi),
gini_rank = order(gini_index))
```

We can then compute the Spearman correlation by applying the Pearson correlation to the rank variables"

```
cor(hateCrimes$hatecrimes_rank,
hateCrimes$gini_rank)
```

`## [1] 0.057`

We see that this is much smaller than the value obtained using the Pearson correlation on the original data. We can assess its statistical signficance using randomization:

`## [1] 0.0014`

Here we see that the p-value is substantially larger and far from significance.