Chapter 14 · Statistics and data analysis

Reading and Building Two-Way Frequency Tables

Sort one group by two questions at once. Learn to read joint cells and totals in a two-way table, then build a table from a list or from stated facts.

16 min read

You already know how to summarize one set of data, such as how many students walk to school. Now suppose you ask each student two questions: What grade are you in? and How do you usually get to school?

Each answer is a category: a group name, not a measurement. What a question records, such as grade, is a categorical variable: its values are categories. The people or things you collect data from are the subjects.

A two-way frequency table sorts the same subjects by two categorical variables at once. One variable labels the rows and the other labels the columns. Every number in the table is a frequency: an exact count of subjects, so it is a whole number that is 00 or greater.

The table below shows the answers of 7070 students. Each student is in exactly one grade and gave exactly one of the three ways of getting to school.

How 70 students usually get to school, by grade
GradeWalkBusCarTotal
Grade 7
99
1717
66
3232
Grade 8
1515
1111
1212
3838
Total
2424
2828
1818
7070

The table holds three kinds of numbers.

  • A joint cell sits where a row meets a column. It counts the subjects in two categories at once, one from each variable. The 1717 means that 1717 students are in Grade 7 and take the bus.
  • A marginal total, or margin, sits at the edge of the table, in the Total row or the Total column. It counts the subjects in one category. The 3838 means that 3838 students are in Grade 8, however they travel. The 2424 means that 2424 students walk, whatever their grade.
  • The grand total, 7070, sits in the corner. It counts every subject once.

These numbers fit together. Add across the Grade 7 row: 9+17+6=329 + 17 + 6 = 32. Add down the Walk column: 9+15=249 + 15 = 24. The sums match the margins because each student is counted in exactly one joint cell.

Key concept

One subject, one joint cell

A joint cell counts the subjects that belong to two categories at once, one from each variable. A margin counts the subjects in one category. The grand total counts all the subjects.

Suppose every subject belongs to exactly one category of each variable. Then every subject is counted in exactly one joint cell. So the joint cells in a row add to that row's total, the joint cells in a column add to that column's total, and the row totals and the column totals each add to the grand total.

sum of row totals=sum of column totals=sum of joint cells=grand total\text{sum of row totals} = \text{sum of column totals} = \text{sum of joint cells} = \text{grand total}

Worked example

Read and interpret the travel table

Use the table of 7070 students to answer four questions. (a) How many Grade 8 students take the bus? (b) How many students come by car? (c) How many Grade 7 students do not walk? (d) Of the students who walk, how many are in Grade 7?

  1. (a) The question names one category from each variable: Grade 8 and Bus. That points to a joint cell. Go along the Grade 8 row until you reach the Bus column.

    Grade 8 and Bus=11\text{Grade 8 and Bus} = 11
  2. (b) The question names one category, Car, and says nothing about grade. That points to a margin: the Car column total, 18. You can confirm it by adding the Car column, because each student who comes by car is in exactly one of the two grades.

    6+12=186 + 12 = 18
  3. (c) The group that does not walk covers two categories in this table: Bus and Car. Each Grade 7 student is counted in exactly one of the three joint cells in the Grade 7 row, so add the Bus and Car cells. Subtracting the Walk cell from the row total gives the same count.

    17+6=2332−9=2317 + 6 = 23 \qquad 32 - 9 = 23
  4. (d) The words 'of the students who walk' set the reference group: the Walk column. Its total is 24, which is not zero, so there is a group to compare with. Inside that column, read the Grade 7 cell. It is a joint cell, and now you also say which total it is part of.

    Walk column total=24Grade 7 and Walk=9\text{Walk column total} = 24 \qquad \text{Grade 7 and Walk} = 9

Answer

(a) 1111 Grade 8 students take the bus. (b) 1818 students come by car. (c) 2323 Grade 7 students do not walk. (d) 99 of the 2424 students who walk are in Grade 7.

Now build a table yourself. You start with raw data: a list that gives two answers for each subject. To turn the list into a two-way frequency table:

  1. Name the two variables and list the categories of each. Choose categories so that every subject fits exactly one category of each variable.
  2. Put one variable in the rows and the other in the columns. Swapping them changes the layout, not the counts. Add a Total row and a Total column.
  3. Tally each subject once: add one to the joint cell that matches both of its answers.
  4. Add across each row and down each column to fill in the margins. Then add the row totals, and separately the column totals. Both sums give the grand total.
  5. Check that the grand total equals the number of subjects in the list. It must, because each subject is tallied in exactly one joint cell.

The list below has the answers of 1212 club members.

Answers from 12 club members
MemberGradePreferred meeting day
1
Grade 8
Monday
2
Grade 7
Friday
3
Grade 8
Monday
4
Grade 8
Friday
5
Grade 7
Friday
6
Grade 8
Monday
7
Grade 7
Monday
8
Grade 8
Monday
9
Grade 8
Friday
10
Grade 7
Friday
11
Grade 8
Monday
12
Grade 8
Monday

Worked example

Build a table from a list

Twelve club members each gave their grade (Grade 7 or Grade 8) and the meeting day they prefer (Monday or Friday). Their answers are in the list above. Construct the two-way frequency table.

  1. Name the variables and categories: grade (Grade 7, Grade 8) and preferred day (Monday, Friday). Each member is in exactly one grade and chose exactly one day, so each member belongs in exactly one joint cell. Put grade in the rows and day in the columns.

  2. Tally the Grade 7 row. Count each Grade 7 member once, in the cell that matches both answers. Member 7 is Grade 7 and Monday. Members 2, 5 and 10 are Grade 7 and Friday.

    Grade 7, Monday=1Grade 7, Friday=3\text{Grade 7, Monday} = 1 \qquad \text{Grade 7, Friday} = 3
  3. Tally the Grade 8 row the same way. Members 1, 3, 6, 8, 11 and 12 are Grade 8 and Monday. Members 4 and 9 are Grade 8 and Friday.

    Grade 8, Monday=6Grade 8, Friday=2\text{Grade 8, Monday} = 6 \qquad \text{Grade 8, Friday} = 2
  4. Add across each row to get the row totals. Each sum counts every member of that grade, because each one sits in exactly one of the two day cells.

    1+3=46+2=81 + 3 = 4 \qquad 6 + 2 = 8
  5. Add down each column to get the column totals. Each sum counts every member who chose that day, because each one sits in exactly one of the two grade cells.

    1+6=73+2=51 + 6 = 7 \qquad 3 + 2 = 5
  6. Find the grand total from the row totals and again from the column totals. Both give 12, which matches the 12 members in the list. A different total would show a slip: a member missed, a member tallied twice, or an adding error.

    4+8=127+5=124 + 8 = 12 \qquad 7 + 5 = 12

Answer

The finished table has joint cells 11 and 33 in the Grade 7 row and 66 and 22 in the Grade 8 row, row totals 44 and 88, column totals 77 and 55, and grand total 1212. It is shown below.

Club members by grade and preferred meeting day
GradeMondayFridayTotal
Grade 7
11
33
44
Grade 8
66
22
88
Total
77
55
1212

Worked example

Build a table from stated facts

Sometimes you are given facts instead of a list. A survey asked 5050 students two yes-or-no questions: whether they play an instrument and whether they play a sport. Every student answered both questions. You are told that 2020 students play an instrument, 3131 play a sport, and 1414 play both. Construct the complete two-way frequency table.

  1. Sort the facts by what each one describes. 50 counts all the students, so it is the grand total. 20 (instrument) and 31 (sport) each describe one category, so they are margins. 14 (both) describes a category from each variable, so it is a joint cell. Put instrument (Yes, No) in the rows and sport (Yes, No) in the columns, and write these four numbers in place.

  2. Complete the Instrument Yes row. Each of the 20 instrument players answered exactly one of Yes or No about sport, so the two joint cells in this row add to 20. One of them is 14, so the other is 20 minus 14. It counts the players with no sport.

    20−14=620 - 14 = 6
  3. Complete the Sport Yes column for the same reason: its two joint cells add to 31. One of them is 14, so the other is 31 minus 14. It counts the sport players with no instrument.

    31−14=1731 - 14 = 17
  4. Find the Instrument No row. The two row totals add to the grand total, because each student answered exactly one of Yes or No about an instrument. So this row total is 50 minus 20. Then subtract the 17 already in the row to get the last joint cell.

    50−20=3030−17=1350 - 20 = 30 \qquad 30 - 17 = 13
  5. The two column totals add to the grand total, so the Sport No total is 50 minus 31. Then check it against the two joint cells in that column.

    50−31=196+13=1950 - 31 = 19 \qquad 6 + 13 = 19
  6. Check the whole table. The four joint cells must add to the grand total, because each student is counted in exactly one of them. Every number in the table is also a whole number that is 0 or greater, as a count must be.

    14+6+17+13=5014 + 6 + 17 + 13 = 50

Answer

Of the 5050 students, 1414 play both, 66 play an instrument only, 1717 play a sport only, and 1313 play neither. The row totals are 2020 and 3030, and the column totals are 3131 and 1919. The finished table is shown below.

Instrument and sport answers of 50 students
Plays an instrumentPlays a sport: YesPlays a sport: NoTotal
Yes
1414
66
2020
No
1717
1313
3030
Total
3131
1919
5050

Keep this idea: a two-way frequency table sorts one group of subjects by two categorical variables at once. A joint cell counts the subjects in two categories, one from each variable. A margin counts the subjects in one category.

When every subject fits exactly one category of each variable, each subject is counted in exactly one joint cell. So rows and columns add to their margins, and the row totals and the column totals each add to the grand total. Use these sums to check a table you read and to finish one you build, provided the stated facts give enough independent information to fix every cell.

Next, you will compare a count with a total to get a relative frequency. Each one must name its reference total (a row total, a column total, or the grand total), and that total must not be zero, because you divide by it.