How do we display two categorical variables together, and what do two-way tables and segmented bar graphs reveal?
Topic 2.2 Representing Two Categorical Variables: construct and interpret two-way (contingency) tables and segmented or side-by-side bar graphs for two categorical variables.
A focused answer to AP Statistics Topic 2.2, on building and reading two-way tables and segmented or side-by-side bar graphs for two categorical variables, with marginal totals and a worked table.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this topic is asking
The College Board (Topic 2.2) wants you to display two categorical variables together with a two-way (contingency) table and with segmented or side-by-side bar graphs, and to read the joint and marginal information these displays carry.
The two-way table
A complete table has every cell filled and every margin computed, with the row totals and column totals each summing to the grand total . Filling in margins is not decoration: the marginal totals are needed to compute the proportions of the next topic, and a missing margin is a common reason a table-construction question loses marks.
Joint and marginal distributions
The table carries two kinds of information at once. The joint distribution is the set of cell counts (or cell proportions out of the grand total): it answers "how many are in both this row and this column?" The marginal distribution is given by the margins: a row total describes one variable on its own, ignoring the other. For example, the column totals tell you the overall split of the column variable across everyone, regardless of the row variable. Distinguishing joint from marginal is foundational, because conditional proportions (the next topic) build on both.
Segmented and side-by-side bar graphs
To display two categorical variables graphically, two bar-graph variants are standard. A segmented (stacked) bar graph draws one bar per category of the first variable, divided into segments whose heights show the proportions of the second variable within that category; comparing the segment patterns across bars reveals whether the variables are associated. A side-by-side (clustered) bar graph instead places the second variable's bars next to each other within each group, which can make exact comparisons easier when there are only a few categories. Both displays are usually drawn with relative frequencies (proportions) rather than raw counts when the groups have different sizes, so that the comparison is fair, exactly as in Unit 1. The choice between segmented and side-by-side is largely about readability: segmented bars emphasize parts of a whole, while side-by-side bars emphasize direct category-to-category comparison.
Reading association from the displays
The reason two-way tables and these bar graphs matter is that they reveal association between the two categorical variables. If the proportion preferring coffee is much higher among males than females, the segmented bars for the two sexes look different, and that visible difference is the association. If the variables were unrelated, the breakdown within each group would look the same. So when you read one of these displays, you are really asking "does the distribution of one variable change as I move across the categories of the other?" A strong exam answer names the variables, points to the differing proportions, and states the association in context, while remembering Topic 2.1's caution that an association in observational data is not proof of cause. The numerical version of this comparison, using conditional proportions, is exactly what Topic 2.3 formalises, so a clean two-way table here sets up the next topic directly.
Try this
Q1. In a two-way table, what do the column totals describe? [1 point]
- Cue. The marginal distribution of the column variable: that variable on its own, ignoring the row variable.
Q2. Why are relative frequencies preferred over counts in a segmented bar graph comparing two groups of different sizes? [2 points]
- Cue. Proportions put both groups on a per-total scale, so a difference in group size does not distort the visual comparison of the second variable's breakdown.
Exam-style practice questions
Practice questions written in the style of College Board exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
AP 2017 (style)1 marksSection I (multiple choice). In a two-way table, the totals in the right-hand margin (the row totals) give which distribution? (A) The joint distribution (B) The conditional distribution of the column variable (C) The marginal distribution of the row variable (D) The relative frequencies of each cellShow worked answer →
The correct answer is (C).
The row totals in the right margin summarize one variable on its own, ignoring the other; this is the marginal distribution of the row variable. The margins of a two-way table give the marginal distributions.
(A) the joint distribution is the cell counts (or cell proportions). (B) a conditional distribution fixes one variable's category and looks within it. (D) cell relative frequencies are joint, not marginal. The margin totals define marginal distributions.
AP 2020 (style)4 marksSection II (free response). A survey of people records sex (male, female) and whether they prefer tea or coffee. Of males, prefer coffee; of females, prefer coffee. (a) Construct the complete two-way table with marginal totals. (b) State the marginal distribution of beverage preference. (c) Describe one advantage of a segmented bar graph for displaying these data.Show worked answer →
A 4-point question on building and reading a two-way table.
(a) (2 points) Males: coffee , tea . Females: coffee , tea . Table cells: male/coffee , male/tea , female/coffee , female/tea . Column totals: coffee , tea . Grand total (1 point for cells, 1 point for correct margins).
(b) (1 point) Marginal distribution of beverage: coffee , tea (proportions of the whole sample, ignoring sex).
(c) (1 point) A segmented bar graph shows, within each sex, the proportion choosing each beverage, making it easy to compare the conditional distributions of preference between males and females visually.
Markers reward a correct table with margins, the marginal beverage distribution as proportions, and a sensible advantage of the segmented display.
Related dot points
- Topic 2.1 Introducing Statistics - Are Variables Related?: identify questions about the association between two variables, distinguish association from causation, and recognize what two-variable data can answer.
A focused answer to AP Statistics Topic 2.1, on framing questions about the association between two variables, the difference between explanatory and response variables, why association is not causation, and what two-variable data can answer, with worked examples.
- Topic 2.3 Statistics for Two Categorical Variables: calculate joint, marginal, and conditional relative frequencies from a two-way table, and use conditional distributions to judge association.
A focused answer to AP Statistics Topic 2.3, on joint, marginal, and conditional relative frequencies from two-way tables, and using conditional distributions to assess association, with full worked proportion calculations.
- Topic 1.3 Representing a Categorical Variable with Tables: build and interpret frequency and relative frequency tables for a single categorical variable, and read proportions and percentages from them.
A focused answer to AP Statistics Topic 1.3, on building frequency and relative frequency tables for one categorical variable, converting between counts, proportions, and percentages, and interpreting them in context, with worked tables.
- Topic 1.4 Representing a Categorical Variable with Graphs: choose, construct, and interpret bar graphs and other displays of a single categorical variable, and describe the distribution of categories.
A focused answer to AP Statistics Topic 1.4, on displaying one categorical variable with bar graphs (frequency and relative frequency) and pie charts, reading and describing them, and the pitfalls of misleading scales, with worked examples.
- Topic 2.4 Representing the Relationship Between Two Quantitative Variables: construct and describe scatterplots by direction, form, strength, and unusual features, in context.
A focused answer to AP Statistics Topic 2.4, on building scatterplots and describing them by direction, form, strength, and unusual features (the DUFS framework), in context, with a worked description.
Sources & how we know this
- AP Statistics Course and Exam Description — College Board (2020)