SECTION 1
Historical Context & Motivation
Humans have been organizing information into tables for thousands of years, but the idea of using a table to compare two categorical variables at the same time is surprisingly modern. Before two-way tables existed, researchers struggled to show how two different categories—like gender and voting preference, or age group and product choice—related to each other. The development of these tables gave scientists, doctors, and social researchers a powerful tool for spotting patterns in data without complicated math.
1700s • Early Frequency Tables
1900 • Karl Pearson's Chi-Square Test
1930s • Rise of Survey Research
Today • Modern Data Analytics
The central question a two-way table answers is straightforward: How are two categorical variables distributed together, and is there a relationship between them? By the end of this lesson, you will be able to build a two-way table from raw data and extract three types of relative frequencies that reveal different layers of the story your data is telling.
SECTION 2
Core Principles & Definitions
Before diving into calculations, you need a solid grasp of the vocabulary. A two-way table (also called a contingency table) displays the counts for every combination of two categorical variables. One variable defines the rows and the other defines the columns. The cells inside the table hold the counts, and the edges hold the totals.
Joint Frequency
Marginal Frequency
Conditional Relative Frequency
Grand Total
KEY TAKEAWAY
SECTION 3
Visual Explanation — Anatomy of a Two-Way Table
The diagram below shows a two-way table for a survey of 200 students who were asked about their preferred study method (alone or in a group) and whether they earned an A on the last exam. Study the layout carefully—notice where the joint frequencies, marginal totals, and grand total are placed.
Notice that each row total equals the sum of its interior cells: 40 + 60 = 100 for students who study alone, and 50 + 50 = 100 for students who study in a group. Similarly, each column total is the sum down that column: 40 + 50 = 90 students earned an A, and 60 + 50 = 110 did not. The grand total—200—can be found by adding either the row totals (100 + 100) or the column totals (90 + 110). This internal consistency is your best error-check when building tables.
SECTION 4
Mathematical Framework
Once you have a two-way table of raw counts, you can convert those counts into three types of relative frequencies. Each one divides a count by a different total, and each answers a different question.
JOINT RELATIVE FREQUENCY
Divide any interior cell by the grand total. This tells you what fraction of all data points falls into that specific combination. For example, 40 ÷ 200 = 0.20, meaning 20% of all students both study alone and earned an A.
MARGINAL RELATIVE FREQUENCY
Divide a row total or column total by the grand total. This tells you the overall proportion for one category of one variable. For example, 90 ÷ 200 = 0.45, meaning 45% of all students earned an A regardless of study method.
CONDITIONAL RELATIVE FREQUENCY (BY ROW)
Divide an interior cell by its row total. This answers: 'Given that a student studies alone, what proportion earned an A?' For example, 40 ÷ 100 = 0.40, so 40% of alone-studiers earned an A.
CONDITIONAL RELATIVE FREQUENCY (BY COLUMN)
Divide an interior cell by its column total. This answers: 'Given that a student earned an A, what proportion studied alone?' For example, 40 ÷ 90 ≈ 0.444, so about 44.4% of A-earners studied alone.
Common Mistake Alert
SECTION 5
Detailed Breakdown — Comparing Frequency Types
Let's see all three frequency types side by side using the study-method data. The diagram below transforms the same raw data into a joint relative frequency table, then shows how conditional relative frequencies are computed by row. Comparing these three views of the same data is the key to mastering two-way tables.
In the joint relative frequency table (②), notice that all four interior cells plus the four cells add up to 1.00 (or equivalently, both marginal row totals sum to 1.00, and both marginal column totals sum to 1.00). In the conditional table (③), each row sums to 1.00 because we are asking about the distribution within that specific row. If you computed conditional frequencies by column instead, each column would sum to 1.00.
SECTION 6
Worked Example — Building a Two-Way Table from Scratch
A school surveyed 150 students about whether they play a sport (Yes or No) and whether they have a part-time job (Yes or No). The raw data shows: 45 play a sport and have a job, 30 play a sport but have no job, 25 do not play a sport but have a job, and 50 neither play a sport nor have a job. Let's construct the two-way table and compute all three types of relative frequencies.
Full Two-Way Table Analysis
- 1
Step 1 — Set Up the Table with Raw Counts
Place one variable (Sport: Yes/No) along the rows and the other (Job: Yes/No) along the columns. Fill in the four interior cells with the given counts: 45, 30, 25, and 50.Interior cells: Sport+Job = 45, Sport+No Job = 30, No Sport+Job = 25, No Sport+No Job = 50 - 2
Step 2 — Compute Marginal Totals
Sum each row: Sport row = 45 + 30 = 75. No Sport row = 25 + 50 = 75. Sum each column: Job column = 45 + 25 = 70. No Job column = 30 + 50 = 80. The grand total = 75 + 75 = 150 (or 70 + 80 = 150).Row totals: 75, 75. Column totals: 70, 80. Grand total: 150. - 3
Step 3 — Compute Joint Relative Frequencies
Divide each interior cell by the grand total of 150. Sport+Job: 45 ÷ 150 = 0.30. Sport+No Job: 30 ÷ 150 = 0.20. No Sport+Job: 25 ÷ 150 ≈ 0.167. No Sport+No Job: 50 ÷ 150 ≈ 0.333.30% of all students both play a sport and have a job. - 4
Step 4 — Compute Marginal Relative Frequencies
Divide each marginal total by 150. Sport: 75 ÷ 150 = 0.50. No Sport: 75 ÷ 150 = 0.50. Job: 70 ÷ 150 ≈ 0.467. No Job: 80 ÷ 150 ≈ 0.533.50% of students play a sport; about 46.7% have a job. - 5
Step 5 — Compute Conditional Relative Frequencies (by Row)
To find the conditional relative frequency of having a job given that a student plays a sport, divide 45 by the sport row total of 75: 45 ÷ 75 = 0.60. For no job given sport: 30 ÷ 75 = 0.40. For having a job given no sport: 25 ÷ 75 ≈ 0.333. For no job given no sport: 50 ÷ 75 ≈ 0.667.60% of student-athletes have a job, compared to only 33.3% of non-athletes. This suggests a possible association between playing a sport and holding a part-time job.
| Has Job | No Job | Total | |
|---|---|---|---|
| Plays Sport | 45 (0.30) | 30 (0.20) | 75 (0.50) |
| No Sport | 25 (0.167) | 50 (0.333) | 75 (0.50) |
| Total | 70 (0.467) | 80 (0.533) | 150 (1.00) |
Completed two-way table with counts and joint relative frequencies in parentheses
SECTION 7
Strengths, Limitations & When to Use Each Frequency
Each type of relative frequency answers a different question, and choosing the wrong one can lead to misleading conclusions. The table below summarizes when to use each type and what pitfalls to watch for.
| Frequency Type | Best For | Limitation |
|---|---|---|
| Joint Relative Frequency | Seeing how common a specific combination is within the entire dataset | Does not reveal the internal distribution within a single category; can be misleading when marginal totals are very unequal |
| Marginal Relative Frequency | Understanding the overall breakdown of one variable, ignoring the other | Hides all information about how the two variables interact; gives no insight into association |
| Conditional Relative Frequency | Comparing distributions across groups to detect possible associations between variables | Association does not prove causation; small sample sizes within a row or column can make proportions unreliable |
KEY TAKEAWAY
SECTION 8
Connection to Advanced Topics
Two-way tables are your entry point into a much larger world of statistical analysis. Once you are comfortable computing conditional relative frequencies, you are only a short step away from formal hypothesis testing and probability theory. The table below shows how the concepts you learned today connect to what comes next.
| This Lesson | Advanced Connection |
|---|---|
| Joint relative frequency | Joint probability P(A ∩ B) in probability theory; used in Bayesian analysis |
| Marginal relative frequency | Marginal probability P(A); foundation of probability distributions |
| Conditional relative frequency | Conditional probability P(A | B); directly connects to Bayes' theorem |
| Comparing conditional frequencies across rows | Chi-square test of independence; determines if an observed association is statistically significant |
In AP Statistics and college-level courses, you will use the chi-square test to determine whether the differences you observe in conditional relative frequencies are large enough to be considered statistically significant, or whether they could have occurred just by chance. You will also encounter Simpson's Paradox, a fascinating phenomenon where an association that appears in several groups can reverse or disappear when the groups are combined. Both of these ideas rely heavily on the two-way table skills you are building right now.
SECTION 9
Practice Problems
Use the following two-way table for Problems 1–4. A school asked 250 students whether they prefer online or in-person classes and whether they are in STEM or non-STEM programs.
| Online | In-Person | Total | |
|---|---|---|---|
| STEM | 60 | 40 | 100 |
| Non-STEM | 50 | 100 | 150 |
| Total | 110 | 140 | 250 |
Two-way table for practice problems 1–4
Question 1: CONCEPTUAL
Show answer
Question 2: BASIC CALCULATION
Show answer
Question 3: INTERMEDIATE
Show answer
Question 4: APPLIED
Show answer
Question 5: CRITICAL THINKING
Show answer
SUMMARY
Lesson Summary
Summary
A two-way table organizes data for two categorical variables into rows and columns, with interior cells holding joint frequencies (counts for each combination), edges holding marginal totals (row and column sums), and a grand total in the bottom-right corner. Dividing a cell by the grand total gives a joint relative frequency, dividing a row or column total by the grand total gives a marginal relative frequency, and dividing a cell by its row or column total gives a conditional relative frequency.
Conditional relative frequencies are especially powerful because they let you compare how a variable is distributed within different groups, which is the first step toward detecting an association between two categorical variables. Always remember that association does not imply causation. These skills connect directly to conditional probability and the chi-square test of independence that you will encounter in more advanced statistics courses.