The short answer
Choose the relationship you mean to quantify.
Use Pearson correlation when a linear association is the target and the scatterplot supports that model. Use Spearman correlation when the target is monotonic ordering, when values are meaningfully ordinal, or when ranks better express the question. Neither coefficient detects every kind of relationship.
R's canonical tuna-quality example
The official R cor.test documentation reproduces
Hollander and Wolfe's comparison of Hunter L lightness with
averaged consumer-panel scores for nine lots of canned tuna.
Each row is one lot measured in both ways.
| Lot | Hunter L | Panel score | L rank | Score rank |
|---|---|---|---|---|
| 1 | 44.4 | 2.6 | 3 | 2 |
| 2 | 45.9 | 3.1 | 6 | 4 |
| 3 | 41.9 | 2.5 | 1 | 1 |
| 4 | 53.3 | 5.0 | 8 | 8 |
| 5 | 44.7 | 3.6 | 4 | 5 |
| 6 | 44.1 | 4.0 | 2 | 7 |
| 7 | 50.7 | 5.2 | 7 | 9 |
| 8 | 45.2 | 2.8 | 5 | 3 |
| 9 | 60.1 | 3.8 | 9 | 6 |
Pearson asks how closely the points follow a line
Pearson correlation standardizes the covariance of the two measured variables. For these values, r = 0.5712, with R² = 0.326, an approximate 95% confidence interval from −0.1497 to 0.8956, and a two-sided P = 0.1082.
Here R² describes squared linear association in this sample. It does not show that lightness causes panel preference, establish agreement between two measurement methods, or mean that 32.6% of a biological mechanism has been explained.
Spearman asks how closely the ordering is preserved
With no tied values, replace each column by ranks and compute
ρ = 1 − 6Σd²/[n(n²−1)]. The nine rank differences
have Σd² = 48, so ρ = 0.6000.
Plotwright reports its t-approximation two-sided
P = 0.08762 and approximate Fisher-z 95%
interval −0.1066 to 0.9039.
A better Pearson-versus-Spearman checklist
- Scientific target: Pearson quantifies linear covariation; Spearman quantifies monotonic rank association.
- Measurement scale: meaningful ranks can support Spearman; interpretable numeric spacing can support Pearson.
- Scatterplot: look for curvature, clusters, changing spread, restricted range and influential observations before summarizing.
- Independence: repeated observations from the same subject or batch are not made independent by ranking them.
- Inference: state tails, confidence level, exact or approximate method, and how ties or missing pairs were handled.
A normality test can inform diagnostics, but its P value does not define the research question. Spearman is also not an automatic outlier repair: ranking reduces the impact of marginal magnitude, yet influential bivariate observations can still matter.
A compact reporting template
“Association between Hunter L lightness and mean panel score across nine tuna lots was summarized with a two-sided Spearman rank correlation because monotonic ordering was the stated estimand. The association was positive but imprecise (ρ = 0.600, approximate 95% CI −0.107 to 0.904; t-approximation P = 0.0876). All paired observations were shown in the scatterplot.”
If linear association was the pre-specified target instead, report Pearson's r and its interval, explain why the linear model was plausible, and retain the scatterplot.
What Plotwright checks
Plotwright submits all nine pairs to the production correlation engine. The published-example gate independently reconstructs Pearson's r from centered cross-products and Spearman's ρ from the rank identity with Σd² = 48, then checks the displayed coefficients and P-value convention.
Those checks establish the defined calculations. They cannot establish independent sampling, select a scientific estimand, diagnose every influential observation or turn association into causation.
Sources and reproducibility
- R stats documentation: cor.test—the complete tuna values, directional example, supported coefficients and small-sample inference conventions.
- NIST/SEMATECH: scatter plots—checking linearity, nonlinearity, changing variation, outliers and the limits of causal interpretation.
- Statistical notes for clinical researchers: correlation—the linear-versus-monotonic distinction and rank formulation.
- Plotwright statistical validation—published expected values, tolerances and evidence limits.