Module lessons (3/3)
Correlation and Chi-Square Test
Evaluate linear and monotone relationships with cor()/cor.test() (Pearson/Spearman) and categorical independence with table()/chisq.test().
What you'll learn in this lesson
- Calculate the Pearson linear correlation (
cor(x, y)) and test its statistical significance withcor.test(). - Choose Spearman rank correlation (
method = "spearman") when there are monotonic curved relationships or extreme outliers. - Construct contingency tables with
table()and perform the Chi-Square independence test (chisq.test()). - Recognize the limitations of correlation: nonlinear relationships, confounding variables, and the principle of “correlation does not imply causation.”
Overview
After comparing means between two groups, the natural step is to measure whether two variables move together: if both data are continuous numeric you will use cor() / cor.test(); if instead both variables are categories (e.g. acquisition channel × conversion) you will use table() + chisq.test().
Explore how Pearson's coefficient r changes when you add an anomalous point in the interactive lab:
Sections covered in this lesson
- 1Pearson vs Spearman: linear vs monotonic
- 2Chi-Square test on categorical data (
table()+chisq.test()) - 3Test yourself: guided exercises
- 4Concept check
Unlock "Correlation and Chi-Square Test" and the full Course R curriculum
Evaluate linear and monotone relationships with cor()/cor.test() (Pearson/Spearman) and categorical independence with table()/chisq.test().
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course R plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.