MATH 1 • STATISTICS & PROBABILITY

Two-Way Tables — I can organize categorical data in a two-way table and compute joint and marginal frequencies.

Unlock patterns in categorical data by organizing and analyzing frequencies in a single, powerful table.

Historical Context & Motivation

Humans have always needed ways to compare groups. Whether a government wanted to know how many men and women lived in each province, or a doctor wanted to track which patients recovered based on treatment type, the challenge was the same: how do you organize information about two different categories at the same time? The answer that emerged over centuries is the two-way table, sometimes called a contingency table. It places one categorical variable along the rows and another along the columns, creating a grid where every cell tells a story about how those categories overlap.

1700s
Early Census Tables
European governments began tabulating population data by region and demographic group, laying the groundwork for cross-classified tables.
1900
Karl Pearson & the Chi-Square Test
Karl Pearson introduced the chi-square statistic to test whether the categories in a two-way table are independent, giving these tables a formal statistical purpose.
1930s
Ronald Fisher's Exact Test
Fisher developed an exact test for two-way tables with small sample sizes, showing that even modest data sets could reveal meaningful associations.
Today
Data Science & Everyday Use
Two-way tables appear in medical research, marketing surveys, sports analytics, and social science. They remain a foundational tool for organizing and interpreting categorical data.

The central question this lesson addresses is straightforward but powerful: when you have data on two categorical variables, how do you organize it clearly enough to spot patterns, compute totals, and draw conclusions? Two-way tables give you a structured, visual way to do exactly that.

Core Principles & Definitions

Before you build a two-way table, you need a solid understanding of the key vocabulary. A categorical variable is any variable that describes a quality or category rather than a numerical amount. Examples include favorite genre (action, comedy, drama), lunch choice (pizza, salad, sandwich), or grade level (freshman, sophomore, junior, senior). When you record data on two categorical variables for the same group of individuals, a two-way table is the ideal way to display that information.

1

Two-Way Table

A rectangular grid that displays the frequencies (counts) for every combination of two categorical variables. One variable defines the rows; the other defines the columns.
2

Joint Frequency

The count in an interior cell of the table. It represents how many data points belong to a specific combination of both categories — for example, "sophomores who prefer comedy."
3

Marginal Frequency

The total of a row or column, found in the margins (edges) of the table. It tells you the overall count for one category, regardless of the other variable.
4

Grand Total

The sum of all joint frequencies — the total number of individuals in the data set. It appears in the bottom-right corner of the completed table.
KEY TAKEAWAY
Think of a two-way table like a seating chart at a school dance. Each row could be a grade level, and each column could be a music preference. The number in each cell tells you how many students from that grade chose that type of music. The row totals tell you how many students are in each grade overall, and the column totals tell you how popular each genre is across all grades. The joint frequencies are the individual cells, while the marginal frequencies are the totals along the edges.

Visual Explanation — Anatomy of a Two-Way Table

The diagram below shows a two-way table that records 200 students' preferences for two categorical variables: Grade Level (Freshman or Sophomore) and Favorite Subject (Math, Science, or English). Notice how the interior cells hold joint frequencies, and the rightmost column and bottom row hold marginal frequencies.

Interior cells (e.g., 30, 45, 25) are joint frequencies. The row and column totals in pink are marginal frequencies. The bottom-right value (200) is the grand total.

Each interior cell answers a very specific question. For instance, the cell at the intersection of "Freshman" and "Science" shows 45, meaning exactly 45 freshmen in this data set chose Science as their favorite subject. That is a joint frequency — it sits at the joint intersection of two categories. Meanwhile, the row total of 100 for Freshman is a marginal frequency; it tells you the total number of freshmen surveyed, regardless of their subject preference.

Mathematical Framework

The arithmetic behind two-way tables is straightforward, but the notation helps you communicate precisely. Below are the key formulas you will use when computing frequencies from a two-way table.

MARGINAL FREQUENCY (ROW)
Row Total = f₁ + f₂ + f₃ + … + fₖ
Add every joint frequency across a single row. Each fᵢ is the count in that row's i-th column.
MARGINAL FREQUENCY (COLUMN)
Column Total = f₁ + f₂ + f₃ + … + fₘ
Add every joint frequency down a single column. Each fⱼ is the count in that column's j-th row.
GRAND TOTAL
n = Σ (all joint frequencies) = Σ (row totals) = Σ (column totals)
The grand total n can be computed three ways: sum all interior cells, sum all row marginals, or sum all column marginals. All three methods must give the same answer.
RELATIVE JOINT FREQUENCY
Relative Joint Frequency = (Joint Frequency) ÷ n
Dividing a joint frequency by the grand total converts it to a proportion (decimal) or percentage, showing what fraction of all data points fall in that cell.
💡 Quick Check
Whenever you finish filling in a two-way table, verify your work by summing the row totals and comparing with the sum of the column totals. Both must equal the grand total. If they don't match, recheck your addition.

Joint vs. Marginal Frequencies — A Closer Look

Let's dig deeper into the difference between joint frequencies and marginal frequencies using a new example. Suppose a school surveyed 150 students about their transportation to school (Bus, Car, Walk) and their involvement in after-school activities (Yes or No).

The cyan-shaded interior cells are joint frequencies. The pink totals along the margins are marginal frequencies. The gold value (150) is the grand total. The bottom box demonstrates converting a joint frequency into a relative joint frequency.

Notice in this example that every column marginal equals 50. That is a coincidence of this data set, not a requirement. In general, row totals and column totals can be any values. The only rule is that all marginals must add up to the same grand total. If you ever find a mismatch, go back and recheck your addition — something went wrong in one of the cells.

Worked Example — Building and Analyzing a Two-Way Table

A gym teacher surveyed 120 students about two things: whether they prefer Indoor or Outdoor sports, and whether they are in 9th or 10th grade. Here are the raw results: 35 ninth graders prefer indoor, 25 ninth graders prefer outdoor, 30 tenth graders prefer indoor, and 30 tenth graders prefer outdoor. Build the two-way table, find all marginal frequencies, and compute the relative joint frequency for "10th grade and Outdoor."

Building a Two-Way Table from Survey Data
1
Step 1 — Identify the VariablesThe two categorical variables are Grade Level (9th or 10th) and Sport Preference (Indoor or Outdoor). Grade Level will label the rows, and Sport Preference will label the columns.
2
Step 2 — Fill in the Joint FrequenciesPlace each count in the correct cell. 9th/Indoor = 35, 9th/Outdoor = 25, 10th/Indoor = 30, 10th/Outdoor = 30. These four values are the joint frequencies.
3
Step 3 — Compute Row Marginal FrequenciesSum across each row. For 9th grade: 35 + 25 = 60. For 10th grade: 30 + 30 = 60.
Row totals: 9th = 60, 10th = 60
4
Step 4 — Compute Column Marginal FrequenciesSum down each column. Indoor: 35 + 30 = 65. Outdoor: 25 + 30 = 55.
Column totals: Indoor = 65, Outdoor = 55
5
Step 5 — Verify with the Grand TotalSum of row totals: 60 + 60 = 120. Sum of column totals: 65 + 55 = 120. Both match the number of students surveyed (120). ✓
Grand total: n = 120
6
Step 6 — Compute Relative Joint FrequencyFor "10th grade and Outdoor," the joint frequency is 30. Divide by the grand total: 30 ÷ 120 = 0.25. Convert to a percentage: 0.25 × 100 = 25%.
Relative joint frequency (10th, Outdoor) = 0.25 or 25%
Completed two-way table for the gym teacher's survey
IndoorOutdoorTotal
9th Grade352560
10th Grade303060
Total6555120

Strengths & Limitations of Two-Way Tables

Two-way tables are incredibly useful, but like any tool, they have both strengths and limitations. Understanding these helps you decide when a two-way table is the right choice and when you might need a different approach.

StrengthsLimitations
Simple to construct — requires only counting and addition.Only works for categorical data. Continuous data (like height or weight) must be grouped into categories first.
Makes patterns and associations between two variables immediately visible.Can only handle two variables at a time. Three or more variables require multiple tables or more advanced techniques.
Provides a foundation for more advanced tests like the chi-square test.Shows association but cannot prove causation — correlation is not causation.
Easy to compute relative frequencies and conditional probabilities from the same table.Tables with many rows and columns can become hard to read and interpret.
KEY TAKEAWAY
A two-way table is like a Swiss Army knife for categorical data: compact, practical, and versatile. However, just as a Swiss Army knife can't replace a full toolbox, a two-way table handles two categories beautifully but can't organize three or more variables on its own. For that, you'll eventually need techniques like multi-way tables or log-linear models.

Connection to Conditional Relative Frequency & Probability

Once you are comfortable with joint and marginal frequencies, the next step is conditional relative frequency. Instead of dividing a joint frequency by the grand total (which gives a relative joint frequency), you divide it by the relevant marginal frequency. This answers questions like "Of the students who ride the bus, what proportion do after-school activities?" That's a conditional question — you're restricting your view to just one row or column.

Frequency concepts build on each other
ConceptFormulaWhat It Answers
Joint FrequencyCount in an interior cellHow many individuals share both categories?
Marginal FrequencySum of a row or columnHow many individuals are in one category overall?
Relative Joint FrequencyJoint freq ÷ grand totalWhat proportion of everyone falls in this cell?
Conditional Rel. FrequencyJoint freq ÷ marginal freqGiven one category, what proportion falls in a specific cell?

In future courses, you'll use conditional relative frequencies to determine whether two variables are independent or associated. If the conditional relative frequencies are roughly the same across all rows (or columns), the variables appear independent. If they differ significantly, you have evidence of an association. This idea leads directly into the chi-square test of independence, a cornerstone of statistical inference.

Practice Problems

Use the following data to answer Problems 1–4. A school cafeteria surveyed 200 students on their lunch preference (Pizza or Salad) and their grade (Junior or Senior). The results: 55 juniors chose pizza, 45 juniors chose salad, 60 seniors chose pizza, and 40 seniors chose salad.

PROBLEM 1CONCEPTUAL
In the cafeteria survey described above, identify one example of a joint frequency and one example of a marginal frequency. Explain in your own words what makes them different.
PROBLEM 2BASIC CALCULATION
Build the complete two-way table for the cafeteria survey. Include all joint frequencies, all marginal frequencies, and the grand total.
PROBLEM 3INTERMEDIATE
Compute the relative joint frequency for each of the four interior cells. Express each answer as both a decimal and a percentage.
PROBLEM 4APPLIED
A local newspaper reports: "Most students at the school prefer pizza." Based on the two-way table, is this claim accurate? Use marginal frequencies to justify your answer. Then explain one piece of information the newspaper would need to make a stronger claim.
PROBLEM 5CRITICAL THINKING
Suppose a third category, "Wrap," is added to the lunch choices, and a third grade level, "Sophomore," is added. The new table has some missing values: Sophomore/Pizza = 20, Sophomore/Salad = ?, Sophomore/Wrap = 15, Junior/Pizza = 55, Junior/Salad = 45, Junior/Wrap = ?, Senior/Pizza = 60, Senior/Salad = 40, Senior/Wrap = 25. The grand total is 300. Find both missing values. Then explain the strategy you used and why the grand total serves as a useful check.

Lesson Summary

A two-way table organizes data on two categorical variables into a grid of rows and columns. The interior cells contain joint frequencies — counts that describe how many data points share a specific combination of both categories. The row and column totals are called marginal frequencies, and the bottom-right corner holds the grand total of all observations.

To convert raw counts into proportions, divide a joint frequency by the grand total to get a relative joint frequency. Always verify your table by checking that all row marginals and all column marginals sum to the same grand total. Mastering these skills prepares you for conditional relative frequencies and the chi-square test of independence in future statistics courses.

Varsity Tutors • Math 1 • Two-Way Tables — I can organize categorical data in a two-way table and compute joint and marginal frequencies.