Two-Way Tables

You've surveyed the whole year group: how do they get to school — walk, cycle, or bus? — and you also noted whether each was a boy or a girl. Now the questions pour in. How many girls cycle? What fraction of everyone walks? Are boys more likely to take the bus than girls? A long list of answers would take all evening to sift.

A two-way table tames the lot. It sorts data classified two ways at once into a neat grid, and the row and column totals in the margins unlock every one of those questions with a glance and a quick division.

How the grid is built

A two-way table sorts data by two categories at once: one runs across the columns, the other down the rows. Each inner cell is a count of items that match both labels — its row label and its column label. The totals sit in the margins: a Total column on the right adds up each row, a Total row along the bottom adds up each column.

Suppose we ask every pupil in a class whether they walk, take the bus, or come by car, and we split that by boys and girls. One category (travel) goes across, the other (boys/girls) goes down:

WalkBusCarTotal
Boys85215
Girls67215
Total1412430

Read across the boys' row: 8 + 5 + 2 = 15. Read down the walk column: 8 + 6 = 14. The grand total in the bottom-right corner, 30, is reached either way — across the margins (15 + 15) or along them (14 + 12 + 4) — because every pupil is counted in exactly one cell.

Worked example 1: fill the gaps from the totals

A blank cell is never a mystery — it's forced by its line's total. Here three cells are missing (shown as ?). Use "the row (or column) adds to its total":

WalkCycleBusTotal
Boys9?720
Girls113?20
Total?71340

Worked example 2: turn cells into probabilities

With the table above complete, pick a pupil at random from all 40.

Now a subtler question — "of the girls, what fraction walk?" — restricts us to the girls only, so we divide by the girls' row total, not the grand total: \frac{\text{girls who walk}}{\text{all girls}} = \frac{11}{20} = 0.55. Choosing the right denominator is the whole game — mind the next box.

Seeing it: compare the rows as proportions

A count on its own can mislead when the groups differ in size, so statisticians compare proportions. Using worked example 1 (each row totals 20), turn every cell into a fraction of its row and put the boys' and girls' bars side by side. Where a pair of bars differs, the two categories may be associated.

Walk is 0.45 for boys versus 0.55 for girls — a real gap; cycle and bus are close. The bars make the comparison jump out far faster than the raw grid.

The classic two-way-table trap is dividing by the wrong total. Look carefully at the words "out of":

Same cell on top, different denominator — and very different answers (0.075 versus 0.15). Whenever a question narrows to one group ("of the girls…", "among the bus-takers…"), your denominator shrinks to that group's total. This is exactly the seed of conditional probability — the maths of "given that…".

Two-way tables have a fancier name in the wild: contingency tables, and they're the workhorse of real data analysis. Every census, medical study, and market survey ends up summarised in one — counts of people split by two things at once.

Their real power is comparison. When statisticians line up the proportions across the rows and columns, they're hunting for whether two things are associated: does taking a treatment relate to recovering? Does the advert relate to buying? If the row proportions differ, something's going on. That simple grid of counts is the very first step toward serious statistical inference.

See it explained