Correlation: Pearson & Spearman
Correlation in R with cor.test() — a p-value and 95% confidence interval, when to use Pearson vs Spearman, and why you should always plot the data.
How strongly do two numeric variables move together — from −1 to +1?
Run the code
Everything in the video — edit it and press Run Code to run real R right here, or copy it:
Download this R script · ▶ Open the full playground
When to use it. Use Pearson for a linear relationship between roughly normal variables; switch to Spearman (ranks) for non-linear or non-normal data, or when outliers are present. Always plot the scatter first.
Try the correlation calculator · read Pearson vs Spearman.