why do we need to sometime jitter the data when using correlation (Spearman) in R For some reason when I am computing the spearman, 
cor.test(data$ag, data$co, method = "spearman")

it gives me a warning

Warning message: In cor.test.default(data\$ag, data\$co, method =
  "spearman") :   Cannot compute exact p-value with ties

I googled and people suggested to jitter the data:   
ag.jitter <- jitter(data$ag)
co.jitter <- jitter(data$co)

And now it works without any warning. I wonder what could cause the first warning?
cor.test(ag.jitter, co.jitter, method = "spearman")

 A: In general, in my opinion, modifying your data to use a statistical test with restrictive assumptions (in this case, no ties) is not advisable when an equivalent non-restrictive statistical method exists. Using a Spearman correlation test without an exact p-value, or using Kendall's $\tau$ in place of Spearman's $\rho$ are both valid approaches for data with ties.
As the simulation below illustrates, jittering data can induce fairly large changes in the observed p-values. Using a non-exact correlation test or Kendall's $\tau$ produce more sensible results.
x <- rnorm(1000, sd = 0.1)
x[1:100] <- x[1]
y <- x + rnorm(1000, sd = 1)
y[200:300] <- y[200]

plot(x, y)


cor.test(x, y, method = "spearman")
#> Warning in cor.test.default(x, y, method = "spearman"): Cannot compute exact p-
#> value with ties
#> 
#>  Spearman's rank correlation rho
#> 
#> data:  x and y
#> S = 152678660, p-value = 0.007922
#> alternative hypothesis: true rho is not equal to 0
#> sample estimates:
#>        rho 
#> 0.08392713


pvals <- replicate(1000, 
  cor.test(
    jitter(x),
    jitter(y),
    method = "spearman")$p.value
)

hist(pvals, breaks = "FD")


cor.test(x, y, method = "spearman", exact = FALSE)
#> 
#>  Spearman's rank correlation rho
#> 
#> data:  x and y
#> S = 152678660, p-value = 0.007922
#> alternative hypothesis: true rho is not equal to 0
#> sample estimates:
#>        rho 
#> 0.08392713
cor.test(x, y, method = "kendall")
#> 
#>  Kendall's rank correlation tau
#> 
#> data:  x and y
#> z = 2.6233, p-value = 0.008709
#> alternative hypothesis: true tau is not equal to 0
#> sample estimates:
#>        tau 
#> 0.05590293

