01 / 20

Two-Way Tables
& Frequencies

Learn to organize categorical data and compute joint, marginal, and conditional relative frequencies from two-way tables.

Math 2

What Is a Two-Way Table?

A two-way table (also called a contingency table) displays data for two categorical variables simultaneously. Rows represent one variable, columns represent the other, and each cell shows the count (frequency) of observations that fall into both categories.

Variable 1 Category A Category B Group X Cell Cell Group Y Cell Cell ← Columns = Variable 2 → Rows = Var 1

Three Types of Frequency

Joint Frequency
The count in a single cell of the table: how many items share both categories.
Marginal Frequency
The row total or column total: the sum along an entire row or column.
Conditional Frequency
A frequency restricted to one category: a cell divided by its row or column total.

Why Two-Way Tables Matter

Two-way tables let us detect relationships between categorical variables. For example: Is there an association between a student's grade level and their preferred lunch option? Frequencies alone can mislead when group sizes differ: relative frequencies level the playing field.

Surveys & Polls
Organize responses by two demographic traits to spot patterns.
Medical Studies
Compare treatment vs. control groups across outcome categories.

Formal Definitions

1
Joint Relative Frequency: \(\dfrac{\text{cell count}}{\text{grand total}}\). Shows the fraction of all observations in that cell.
2
Marginal Relative Frequency: \(\dfrac{\text{row or column total}}{\text{grand total}}\). Shows the fraction of observations in that entire row or column.
3
Conditional Relative Frequency: \(\dfrac{\text{cell count}}{\text{row total}}\) or \(\dfrac{\text{cell count}}{\text{column total}}\). Shows the fraction within a specific subgroup.

Anatomy of the Table

Cat. A Cat. B Row Total Group 1 Group 2 Col Total Joint Joint Joint Joint Marginal Marginal Marginal Marginal Grand Total

Joint vs. Marginal vs. Conditional

Feature Joint Marginal Conditional
Numerator Cell count Row or col total Cell count
Denominator Grand total Grand total Row or col total
Question answered "What \(\%\) of all?" "What \(\%\) of the total are in this category?" "What \(\%\) given this group?"
Sum of all values \(1\) \(1\) (per variable) \(1\) (per row/col)

Step-by-Step Method

1
Identify the two variables and list all categories for each.
2
Set up the grid: one variable as rows, the other as columns. Add a "Total" row and column.
3
Tally the data into the appropriate cells (joint frequencies).
4
Compute totals: add across each row and down each column. Verify the grand total.
5
Compute relative frequencies by dividing by the appropriate total (grand, row, or column).

Example: Student Activities

A school surveyed 200 students about their grade level (Junior or Senior) and whether they participate in a sport. Build the two-way table:

Plays Sport No Sport Total
Junior 45 35 80
Senior 70 50 120
Total 115 85 200

Joint Relative Frequencies

Divide each cell by the grand total (\(200\)) to get the joint relative frequency table:

Plays Sport No Sport Total
Junior \(\frac{45}{200} = 0.225\) \(\frac{35}{200} = 0.175\) 0.400
Senior \(\frac{70}{200} = 0.350\) \(\frac{50}{200} = 0.250\) 0.600
Total 0.575 0.425 1.000

Conditional Relative Frequencies

Now divide each cell by its row total to find the conditional relative frequency given grade level:

Plays Sport No Sport Total
Junior \(\frac{45}{80} = 0.5625\) \(\frac{35}{80} = 0.4375\) 1.000
Senior \(\frac{70}{120} = 0.58\overline{3}\) \(\frac{50}{120} = 0.41\overline{6}\) 1.000

From Raw Data to Table

A teacher records whether 150 students prefer online or in-person classes, sorted by whether they have a part-time job:

Online In-Person Total
Has Job 54 36 90
No Job 18 42 60
Total 72 78 150

Conditioning on Columns

We can also divide by column totals instead of row totals. Using the same data: "Of all students who prefer online classes, what fraction has a job?"

Online In-Person
Has Job \(\frac{54}{72} = 0.750\) \(\frac{36}{78} \approx 0.462\)
No Job \(\frac{18}{72} = 0.250\) \(\frac{42}{78} \approx 0.538\)
Total 1.000 1.000

Common Mistakes

✕ Wrong Denominator
Using the grand total when the question asks "given" a subgroup. Conditional frequencies require the row or column total.
✕ Swapping Row & Column
Conditioning on rows when the question asks "of those in column X." Read the problem carefully: "given" or "among" tells you which total to use.
✕ Forgetting to Verify Totals
All joint relative frequencies must sum to \(1.000\). Conditional frequencies in each row (or column) must also sum to \(1\). If they do not, there is an arithmetic error.

Summary at a Glance

Frequency Type Formula Sums To
Joint (raw) Cell value Grand total
Joint relative \(\frac{\text{cell}}{\text{grand total}}\) 1
Marginal relative \(\frac{\text{row/col total}}{\text{grand total}}\) 1 (per variable)
Conditional relative \(\frac{\text{cell}}{\text{row or col total}}\) 1 (per row/col)

Question 1 of 5

A two-way table has a grand total of 300. One cell contains 60. What is the joint relative frequency for that cell?

Question 2 of 5

In a survey of 200 people, 80 are female. The marginal relative frequency for female is:

Question 3 of 5

In a row with a total of 90, one cell has a count of 27. The conditional relative frequency for that cell given its row is:

Question 4 of 5

Use this table. What is the conditional relative frequency of "Cats" given "Adults"?

DogsCatsTotal
Teens302050
Adults4555100
Total7575150

Question 5 of 5

If the conditional relative frequencies for "Plays Sport" are \(56\%\) for juniors and \(58\%\) for seniors, what can you conclude?