---
title: "One table. Two variables. | FiveStudy"
description: "A regional airline tracks 500 flights that left from Denver, Chicago, and Atlanta last month. For each flight it records the departure airport and whether the flight arrived on time or was delayed. Bo"
url: https://fivestudy.com/guides/apstats-2-1-two-way-tables-and-graphs
---

[AP Statistics](https://fivestudy.com/ap-statistics) · Study guide

# One table. Two variables.

[Figure: FiveStudy]

FiveStudy

AP® Statistics · Unit 2 · Probability, Random Variables, and Probability Distributions

AP® Statistics · Unit 2 · Probability, Random Variables, and Probability Distributions

# Two-Way Tables and Graphs for *Two Categorical* Variables

How a two-way table organizes two categorical variables, how side-by-side bar charts, segmented bar charts and mosaic plots compare one variable across the other, and how to tell from them whether the variables are associated.

1. Two-way tables 2. Side-by-side bars 3. Segmented bars 4. Mosaic plots 5. Association

The idea in one paragraph

When each observational unit is sorted by two categorical variables, a **two-way table** shows the counts for every combination. The question is usually whether the variables are related: does one variable’s distribution change from one category of the other to the next? Graphs that compare those distributions group by group, using percents rather than counts, make the answer visible.

## 1 Two-way tables

A survey asked 400 students two questions: “Do you use your phone in bed after lights out?” and “Do you feel rested most mornings?” (yes, sometimes, or no).

|  | Rested: yes | Sometimes | No | Total |
| --- | --- | --- | --- | --- |
| Phone in bed | 48 | 96 | 96 | **240** |
| No phone in bed | 72 | 56 | 32 | **160** |
| **Total** | **120** | **152** | **128** | **400** |

A **two-way table**, also called a contingency table, summarizes data for two categorical variables. One variable’s categories label the rows and the other’s label the columns. The entries in the cells can be frequencies (counts) or relative frequencies (proportions).

**Figure 1.** Each of the 400 students lands in exactly one cell: one row (phone use) and one column (rested or not). The cells add across to the row totals and down to the column totals, and everything adds to 400.

Worked Example 1 Read the table

### Phones and sleep

Use the two-way table of 400 students. (a) How many students use a phone in bed? (b) How many feel rested most mornings? (c) How many use a phone in bed and do not feel rested? (d) What percent of all 400 students keep the phone out of bed and feel rested?

1. 1(a) The row total for phone in bed: 240 students.
2. 2(b) The column total for rested yes: 120 students.
3. 3(c) The cell where the phone-in-bed row meets the rested-no column: 96 students.
4. 4(d) The no-phone, rested-yes cell is 72 students, and \(72 \div 400 = 0.18\), or 18% of all students.

**Answer:** 240, 120, 96, and 18%. A row or column total answers questions about one variable; a cell answers questions about both at once.

## 2 Side-by-side bar charts

Graphs of two categorical variables show, for each category of one variable, the frequency or relative frequency of each category of the other. A **side-by-side bar chart** puts a cluster of bars for each group next to each other.

**Figure 2.** Within each group, the bars show how that group splits on feeling rested. Percents, not counts, because the groups have different sizes: 240 use a phone in bed, 160 do not.

Common Mistake 1 · Graphing counts for groups of different sizes

Phone users who do not feel rested (96) outnumber non-users who feel rested (72), but there are 240 phone users and only 160 non-users. Bars of counts mix up “how common” with “how big the group is.” Use percents within each group.

## 3 Segmented bar charts

A **segmented bar chart** gives each group one bar that reaches 100%, cut into segments for the categories of the other variable. Because every bar has the same height, the segments can be compared directly.

**Figure 3.** Each bar is one group, stretched to 100% and cut into pieces for the other variable. The teal “rested: yes” piece is more than twice as big for students who keep the phone out of bed.

Worked Example 2 Build a segmented bar chart

### From counts to percents

Describe how to turn the table into the segmented bar chart in Figure 3.

1. 1Decide which variable makes the bars. To compare phone users with non-users, use one bar per phone group.
2. 2Within each phone group, divide each cell by that group’s row total. Phone in bed: \(48 \div 240 = 0.20\), \(96 \div 240 = 0.40\), \(96 \div 240 = 0.40\).
3. 3No phone in bed: \(72 \div 160 = 0.45\), \(56 \div 160 = 0.35\), \(32 \div 160 = 0.20\).
4. 4Draw each bar to 100% and stack the pieces in the same order in every bar, with a key.

**Answer:** Two 100% bars: 20/40/40 for phone users and 45/35/20 for non-users, segments in the same order with a key.

Common Mistake 2 · Segments that do not add to 100%

Each bar’s segments must be percents of *that bar’s group*, so they add to 100%. If you divide by the grand total (400) or by a column total instead, the bars will not reach 100% and the comparison falls apart.

## 4 Mosaic plots

A **mosaic plot** is a segmented bar chart whose bar widths are proportional to the size of each group. The heights show the split within each group, and the widths show how big each group is, so it displays both variables’ distributions in one picture.

**Figure 4.** A mosaic plot shows both variables at once. The heights inside each column give the percents within that group, and the column widths show that 60% of the students surveyed use a phone in bed.

Worked Example 3 Justify a claim with the mosaic plot

### Most students use a phone in bed

A claim says: “Most of the students surveyed use a phone in bed after lights out.” Use Figure 4 to decide whether the data support it.

1. 1In a mosaic plot, the width of each column shows the size of that group.
2. 2The phone-in-bed column takes 60% of the width: 240 of the 400 students.
3. 360% is more than half, so “most” is justified.

**Answer:** Supported. 240 of the 400 students, or 60%, use a phone in bed, which is more than half.

Common Mistake 3 · Ignoring the widths in a mosaic plot

In a mosaic plot the width carries information. A wide column is a big group. The area of each tile is proportional to its cell count: the large “phone in bed, rested: no” tile is 96 students out of 400.

## 5 Association

Two categorical variables are **associated** if knowing the category of one changes the distribution of the other. Graphically: if the bars for the groups are split differently, the variables are associated. If every group is split about the same way, there is no association.

**Figure 5.** Two categorical variables are *associated* when the distribution of one changes across the categories of the other. If every group splits the same way, knowing the group tells you nothing new: no association.

Worked Example 4 Is there an association?

### Use the graph

Based on Figure 3, is using a phone in bed associated with feeling rested for these students? Back up your answer.

1. 1If the variables were not associated, the two bars would be split about the same way.
2. 2They are not: 45% of students who keep the phone out of bed feel rested most mornings, compared with 20% of those who use it in bed.
3. 3And 40% of phone-in-bed students do not feel rested, compared with 20% of the others.

**Answer:** Yes. The distribution of feeling rested differs clearly between the groups: students who keep the phone out of bed were more than twice as likely to say they feel rested (45% compared with 20%).

Worked Example 5 What does the association allow?

### Cause or not?

A student writes: “The survey proves that using a phone in bed makes students tired.” What is wrong with the claim?

1. 1The data come from a survey, an observational study. Nobody was assigned to use or avoid the phone.
2. 2Other variables could explain the link. Students with more homework or more stress might both use the phone late and sleep worse.
3. 3An association in observational data does not show cause and effect.

**Answer:** The survey shows an association, not a cause. A fair statement is: “Students who used a phone in bed were less likely to report feeling rested.”

Say it like this

Compare the same category across groups with numbers from the graph: “Students who kept the phone out of bed were more likely to feel rested most mornings than students who used it in bed (45% compared with 20%), so phone use and feeling rested are associated for these students.”

Common Mistake 4 · Calling an association a cause

A survey can show that two categorical variables are associated, not that one causes the other. Write “were more likely to,” not “makes” or “causes,” unless the data come from an experiment with random assignment.

### Quick reference

| Display | What it shows best |
| --- | --- |
| Two-way table | Exact counts for every combination, plus row and column totals |
| Side-by-side bar chart | Each category compared across groups, bar by bar |
| Segmented bar chart | How each group splits, on bars of equal height (100%) |
| Mosaic plot | How each group splits, plus how big each group is (bar widths) |

FiveStudy AP® Statistics · Two-way tables and graphs
