On this concept: Formula

Not sure which lesson to do first? Find your level and get a plan →

Math · Statistics & Probability · Grade 6-8

Two-Way Tables

A two-way table displays counts for two categorical variables at once, with one variable in rows and the other in columns; cells are joint frequencies, edge totals are marginal frequencies, and cell-over-margin gives conditional frequencies.

P(A|B) = \frac{\text{joint frequency of } A

Quick Answer

A two-way table displays counts for two categorical variables at once, with one variable in rows and the other in columns; cells are joint frequencies, edge totals are marginal frequencies, and cell-over-margin gives conditional frequencies. Use it when each person or item is sorted two ways at once, such as by grade and favourite sport, or by vaccinated and got sick. The table lets you compare groups fairly: divide a cell by its row or column total to compare percentages instead of raw counts.

Why This Matters

Raw counts mislead when groups have different sizes. If 30 seventh graders and 20 sixth graders prefer basketball, seventh graders look keener, but if there are 100 seventh graders and 40 sixth graders, the rates are 30% and 50%. A two-way table puts those group totals in its margins, so you can turn counts into percentages and see whether the two variables are related at all.

Intuitive Explanation

Survey 55 students with two questions: which grade are you in, and which do you prefer, soccer or basketball? Each student lands in exactly one of four boxes: 6th and soccer, 6th and basketball, 7th and soccer, 7th and basketball. Put grades down the side, sports across the top, and write the counts in the boxes: 15, 10, 12 and 18. These inner counts are joint frequencies, because each one describes two facts at once.

Add across each row and down each column, and write the totals on the edges, the margins: 25 sixth graders, 30 seventh graders, 27 soccer fans, 28 basketball fans, 55 in all. These marginal frequencies each describe one variable and ignore the other. Now you can compare fairly: 18 of the 30 seventh graders chose basketball, which is 60%, while 10 of the 25 sixth graders did, which is 40%. Each of those is a conditional frequency, a cell divided by the total of the group you are looking at.

Not every grid is a two-way table. A grid of test scores, with students down the side and subjects across the top, holds measurements, not counts of people in categories, and adding a column gives a total score, which means something quite different. In a two-way table each inner number counts how many individuals fall into a pair of categories, and every individual is counted exactly once.

Think of it like this. A two-way table is like a sock drawer with dividers running both ways: one set separates colours, the other separates sizes. Each compartment holds one colour-and-size combination, the totals on the edges count all the black socks or all the large ones, and every sock sits in exactly one compartment.

Core idea. A two-way table arranges counts for two categorical variables in rows and columns, with margins as totals.


When to Use

Use a two-way table when each individual is classified by two categorical variables at once (grade and sport, treatment and outcome), or when a question asks for a share of one group, such as 'what percent of the 7th graders'. Divide by a row or column total for those conditional questions and by the grand total for joint ones. If only one variable is recorded, a one-variable frequency table is enough; numeric measurements belong in a histogram or dot plot.

Tip. Ask: Are two categorical variables being crossed in a grid so each cell counts a combination of one category from each?

How to Recognize It

Before reading or building a two-way table, check what was recorded about each person and which group a question's percentage is taken out of.

  1. Could one person belong to two categories of the same variable, such as a student who plays two sports?

    If yes, the table cannot hold the data as it stands, because each person must land in exactly one cell. Make a rule, such as counting only each student's main sport, or use a different display.

  2. Are both things recorded as categories, rather than measured numbers like height or test score?

    If yes, a two-way table fits. If one variable is a measurement, show it with a histogram or dot plot for each group; if both are measurements, use a scatter plot.

  3. Does the question ask for a share of one particular group, as in what percent of the 7th graders own a pet?

    If yes, divide the cell by that group's row or column total; this is a conditional frequency. If it asks what percent of all students are 7th graders who own a pet, divide by the grand total instead.

  4. Do the groups being compared have very different sizes?

    If yes, compare percentages within each group, not raw counts: 30 of 200 is a smaller share than 20 of 50. Similar percentages across groups suggest the variables are not associated; very different percentages suggest they are.

Two-Way Tables compared with Conditional probability, Frequency table (one variable), and Histogram

All four rows organize counts or chances from data. Ask how many variables there are and of what kind: two categorical variables crossed (two-way table), one categorical variable (frequency table), one numeric variable in bins (histogram), or a chance computed from the table (conditional probability).

Two-Way Tables

Meaning
Use this when you have two categorical variables and need to organize their counts to compare or compute conditional frequencies.
Key test
Are two categorical variables being crossed in a grid so each cell counts a combination of one category from each?
Formula
P(A∣B)=joint frequency of A and Bmarginal frequency of B
Example
Of 100 surveyed students, the 9th-grade row totals 40, and 24 of those 9th graders chose soccer. Find the conditional frequency of soccer given 9th grade.

Conditional probability

Meaning
The probability formula a two-way table feeds; the table is the display, not the computation.
Key test
Use when computing P(A∣B) from the table's cells and margins.
Formula
P(A∣B)=jointmarginal of B
Example
P(soccer | 9th grade) from the grid

Frequency table (one variable)

Meaning
Counts a SINGLE categorical variable, with no crossing.
Key test
Use when only one category dimension matters.
Example
Just counts of favorite sport overall

Histogram

Meaning
Displays a NUMERIC variable's distribution in bins, not crossed categories.
Key test
Use when the variable is quantitative, not categorical.
Example
Distribution of test scores

Formula & Notation

P(A∣B)=joint frequency of A and Bmarginal frequency of B
P(A∩B)=nABn; P(A∣B)=nABnB where nAB is the joint count and nB is the marginal count for B

How to read it: Joint frequency: count in a single cell. Marginal frequency: row or column total. Conditional frequency: cell ÷ row (or column) total.

Worked Examples

Example 1 — Sport by grade

Easy

Of 100 surveyed students, the 9th-grade row totals 40, and 24 of those 9th graders chose soccer. Find the conditional frequency of soccer given 9th grade.
Show the steps and the answer
  1. Find the group the question conditions on: 'given 9th grade' means only the 40 ninth graders count.

    A conditional frequency restricts attention to one row of the table.

  2. Find the cell inside that row: 24 ninth graders chose soccer.

    The cell is where the 9th-grade row and the soccer column cross.

  3. Divide the cell by the row total: 2440=0.6=60%.

    The other 60 students are outside the group, so they do not belong in the denominator.

Answer: 60% of 9th graders chose soccer

Takeaway: 'Given' or 'of the ...' tells you which total to divide by: the row or column for that group.

Example 2 — Joint instead of conditional

Standard

Same survey: what FRACTION OF ALL 100 students are 9th graders who chose soccer?
Show the steps and the answer
  1. Read the denominator from the question: 'of all 100 students'.

    The question now asks about everyone surveyed, not only the ninth graders.

  2. Divide the same cell by the grand total: 24100=0.24.

    This joint relative frequency is the share of everyone who is both a ninth grader and a soccer fan.

  3. Compare with the conditional answer: 0.24 here versus 0.60, from the same cell of 24.

    The numerator did not change; only the group it is compared with did.

Answer: 24100=0.24

Takeaway: Same cell, different totals: divide by the grand total for a joint frequency and by a row or column total for a conditional one.

Example 3 — Find the mistake: row total or column total?

Application

A table shows 6th grade: 15 soccer, 10 basketball (total 25); 7th grade: 12 soccer, 18 basketball (total 30); column totals 27 soccer and 28 basketball; 55 students in all. Question: what percent of the soccer players are 7th graders? Priya writes: "1230=40%." Find the mistake and correct it.
Show the steps and the answer
  1. Find the group in the question: 'of the soccer players', so the whole is the soccer column, 27 students.

    The words after 'of the' name the group you are restricting to.

  2. See what Priya did: 30 is the 7th-grade row total, so 1230 answers 'what percent of 7th graders play soccer?'

    Swapping the row total for the column total swaps the question being answered.

  3. Divide by the column total: 1227≈0.444=44.4%.

    The 12 seventh-grade soccer players are counted out of all 27 soccer players.

  4. Check: the 6th graders' share of soccer players is 1527≈55.6%, and 44.4%+55.6%=100%.

    Within one column, the shares of the two grades must add to 100%.

Answer: 1227≈44.4% of the soccer players are 7th graders

Takeaway: Before dividing, find the group named after 'of the' and use its total, whether that is a row or a column.

Where You'll See It

  • Judging a vaccine trial

    In a trial, 20 of 1,000 vaccinated people and 100 of 1,000 unvaccinated people got sick. A two-way table (vaccinated or not, sick or not) gives sick rates of 2% and 10%, so the vaccine cut the rate of illness by 80%.

  • Planning a shop's online ads

    A shop sold 300 pairs of shoes online and 100 in store, and 100 coats online and 400 in store. Dividing by each product's total shows 75% of shoe sales but only 20% of coat sales happen online, so shoe ads belong online.

Common Mistakes

  1. The slip: Confusing joint, marginal, and conditional frequencies

    Instead: joint is one cell's count (divide by the grand total for a joint relative frequency), marginal is a row/column total, conditional is a cell over a row (or column) total.

  2. The slip: Dividing a cell by the grand total when a conditional is asked

    Instead: condition on the given group by dividing by that row or column total.

  3. The slip: Putting a numeric variable in the table

    Instead: two-way tables cross two CATEGORICAL variables, not measurements.


Mini Practice

Try these on your own. Tap Reveal when you want to check.

  1. In a survey of 80 students, 30 are 7th graders and 20 of those prefer dogs. In all, 45 students prefer dogs. The rest are 8th graders. How many 8th graders prefer cats?

    Hint: Find how many 8th graders there are and how many of them prefer dogs.

  2. Using this table (7th grade: 20 dog, 10 cat; 8th grade: 25 dog, 25 cat; 80 students in all), what fraction of all students are 7th graders who prefer cats?

    Hint: This is a joint frequency, so divide by the grand total.

  3. Using this table (7th grade: 20 dog, 10 cat; 8th grade: 25 dog, 25 cat; 80 students in all), what percent of 8th graders prefer dogs, and what percent of dog lovers are 8th graders?

    Hint: Each question names a different group to divide by.

  4. Using this table (7th grade: 20 dog, 10 cat; 8th grade: 25 dog, 25 cat; 80 students in all), is preferring dogs associated with grade? Compare conditional percentages.

    Hint: Find the percent of each grade that prefers dogs.

  5. You record the heights in cm of 30 students and want to show their distribution. Two-way table or histogram?

    Hint: Is height a category or a measurement?

  6. Asked what fraction of 8th graders prefer cats (8th grade: 25 dog, 25 cat; 80 students in all), Raj writes 2580. Correct his work.

    Hint: The question is about 8th graders only. What total should you divide by?

Want the full set?

50 practice questions for this concept — free to try, every one with a complete worked solution showing the why, not just the answer.

Frequently Asked Questions

Can row percentages and column percentages tell different stories?

They answer different questions, so they can look quite different. Suppose 20 of 50 seventh graders play an instrument, and 20 of the 45 students who play are seventh graders. The first says 40% of seventh graders play; the second says about 44% of players are seventh graders. Before dividing, decide which group you are taking a share of; that group's total goes on the bottom.

What is Simpson's paradox?

It is when a pattern that holds in every group reverses once the groups are combined. In a well-known 1986 study of kidney stone treatments, one treatment had a higher success rate for small stones and for large stones, yet a lower rate overall. The other treatment had mostly been given to patients with small stones, which are easier to treat. Splitting a two-way table by a third variable can reveal such a hidden factor.

Why do the totals in a two-way table have to match?

Every person is counted in exactly one cell, so adding the row totals and adding the column totals both give the same grand total. That is a handy check and a way to fill in missing numbers. If a table shows 50 seventh graders and 20 of them play an instrument, the cell for seventh graders who do not play must be 50−20=3050 - 20 = 30. Many test questions are built on filling gaps this way.

Does a two-way table show that one variable causes the other?

No. It can show an association: for example, students who play a team sport might be more likely to say they enjoy school. But the table cannot tell whether sport makes school more enjoyable, whether students who already enjoy school join more teams, or whether a third factor, such as having more friends, drives both. Testing a cause takes an experiment that assigns the treatment at random.

Learning Path

Two-Way Tables

You are here

You need Fractions and Ratios (turning a count out of a total into a percent) and basic Probability. A two-way table adds a way to organise two categories at once and to read joint, marginal and conditional frequencies. It leads to Conditional Probability, the Chi-Square Test of whether two variables are related, Correlation for numeric pairs, and spotting Sampling Bias in survey data.

See Also