Start With the Unit You Want Each Row to Represent
A data table’s layout should reflect the question being asked. If the question concerns students, a useful table may have one row per student. If it concerns appointments, each row may instead represent one appointment—even when the same patient has several appointments. Choosing a layout therefore begins with a decision about the observational unit: what one row is intended to describe.
A one-row-per-unit layout is often convenient when each unit has one value for each recorded characteristic. It makes the table easy to scan and helps prevent accidental counting of the same unit more than once. But it is not a universal rule that every person, animal, or object must appear exactly once. Repeated measurements and event-based questions often require multiple rows for one person or other larger unit.
A row is not automatically a person. A row might describe one visit made by a person, one day of monitoring, or one school. Nor does choosing one row per person mean that all information must be reduced to a single number. The key is that each row has a clear and consistent meaning.
What One Row Per Unit Requires
Suppose the question is about \(N\) distinct students, and every student is intended to contribute one row. A correct one-row-per-student layout has \(N\) rows: no student has two rows, and no intended student is left without a row. This is a structural condition, not a statistical assumption about how the students were selected or how their measurements behave.
That equality applies when the table contains one row for every intended unit. If a unit has no recorded value for a particular measurement, the row can still represent that unit; an unrecorded value does not by itself create a second unit. Conversely, if the table has more rows than intended units, check whether some units have multiple records or whether the row definition is actually a smaller unit, such as a visit or measurement occasion.
A simple way to check the layout is to state the meaning of a row in words, then ask whether every row fits that description and whether each intended unit appears once. If either answer is no, the layout may not match the question.
Decide whether the question is about people, events, occasions, or another entity.
For example, “one row describes one student” or “one row describes one appointment.”
Confirm that each intended unit appears once, and that each row represents only one such unit.
If the question concerns separate occasions or events, do not combine them merely to obtain one row per person.
Worked Example: Combining Student Records Into One Row
Suppose a hypothetical class data file has one record for each student-and-measurement combination. The intended question concerns the students, and each student has exactly one recorded value for each of two measurements. The source table is:
| Student | Measurement | Value |
|---|---|---|
| A | Study hours | 4 |
| A | Quiz score | 78 |
| B | Study hours | 6 |
| B | Quiz score | 85 |
| C | Study hours | 3 |
| C | Quiz score | 72 |
Choose the unit. The question is about students, so each intended row should describe one student. The six source rows do not describe six students: they describe two recorded measurements for each of three students.
Reshape the values. Put each measurement in its own column, matching records that belong to the same student:
| Student | Study hours | Quiz score |
|---|---|---|
| A | 4 | 78 |
| B | 6 | 85 |
| C | 3 | 72 |
Check the result. There are three intended student units and three rows. Each student appears once, and each row gives that student’s value for both measurements. The new table now has the one-row-per-student layout requested by the question. This reshape is appropriate here because there is exactly one value per student for each measurement; if there were several quiz scores per student, the same operation would require another decision about what the rows should represent.
Repeated Measurements May Need Multiple Rows
A person can be measured more than once. Whether those records belong in one row or several depends on what counts as a unit for the question. If the question compares participants’ values at two fixed occasions, a wide layout with one row per participant and separate columns for the occasions can be useful. If the question concerns the sequence of observations across occasions, a long layout with one row per participant per occasion preserves that structure directly.
Neither layout is automatically the correct one for every purpose. The important point is to say what each row means and not to treat repeated observations as though they were separate people. A table with several rows per participant can be well organized when a row represents one occasion. It simply is not a one-row-per-participant table.
Worked Example: Choosing a Layout for Repeated Measurements
Imagine a hypothetical exercise session in which three participants have their pulse recorded at the start and ten minutes later. The observations are:
| Participant | Occasion | Pulse (beats per minute) |
|---|---|---|
| A | Start | 72 |
| A | 10 minutes | 96 |
| B | Start | 68 |
| B | 10 minutes | 88 |
| C | Start | 75 |
| C | 10 minutes | 100 |
If the intended unit is a participant and the purpose is to place the two recorded occasions side by side, reshape to:
| Participant | Pulse at start | Pulse at 10 minutes |
|---|---|---|
| A | 72 | 96 |
| B | 68 | 88 |
| C | 75 | 100 |
This layout has three rows for three participants. The occasion is represented by the two measurement columns, so the two values for each participant remain distinguishable.
If the intended unit is a participant-occasion combination, keep the original six-row layout. Each row represents one pulse measurement at one occasion. This layout is appropriate for questions that need to refer to each occasion as a separate record. It would be a mistake to call those six rows six participants: there are three participants, each with two measurements.
The choice depends on the question, not on a general preference for fewer rows. Combining the observations into one row per participant is suitable only if the occasion-specific values are kept distinct. Replacing both values with one average, for example, would remove the difference between the start and later measurements from the table.
Events Can Be the Units, Even When People Repeat
Multiple rows for one person are also appropriate when the row describes an event. For instance, if a question is about the length of appointments, the appointment—not the patient—may be the intended unit. A patient with three appointments then contributes three rows. If the question is instead about patients, the analyst must decide how the patient-level information will be represented; silently keeping one arbitrary appointment would change the data and potentially the question.
Worked Example: Several Appointments for One Patient
Consider this hypothetical appointment log:
| Patient | Appointment | Waiting time (minutes) |
|---|---|---|
| A | 1 | 12 |
| A | 2 | 20 |
| B | 1 | 9 |
| C | 1 | 15 |
| C | 2 | 11 |
For an appointment-level question, such as describing waiting times across appointments, the intended units are the five appointments. The five rows are appropriate: patients A and C each appear twice because each had two distinct appointments. There are five event units, not three.
For a patient-level question, such as describing one waiting-time summary per patient, the intended units are the three patients. A one-row-per-patient table would need one defined patient-level value. For example, if the chosen summary is the mean waiting time across that patient’s appointments, the values are:
The resulting patient-level summary has three rows, with waiting times of 16, 9, and 13 minutes for A, B, and C. But that table answers a different question from the appointment-level table: it summarizes each patient’s appointments rather than retaining each appointment as a separate observation. The choice of summary must therefore be part of the question, not an accidental consequence of reshaping.
Why the Row Definition Matters
A row layout determines what the entries in the table describe and what a row count means. In a one-row-per-person table, the row count can represent the number of people represented. In an appointment table, it represents appointments, and the same person may contribute repeatedly. Confusing those meanings can lead to incorrect descriptions of the data and poorly matched analyses.
The layout alone does not determine whether rows are statistically independent, whether a study supports a causal conclusion, or which regression model is appropriate. Those are separate questions. In particular, placing repeated measurements in separate rows does not make them measurements from different people. The row structure should accurately preserve the observational units before later analysis choices are made.
Common Mistakes
- Assuming every person should appear once. This is wrong when the intended units are visits, events, or measurement occasions. Define the unit from the question.
- Counting rows as people without checking. Several rows may belong to one person. Count the intended units, not just the records.
- Combining repeated values without stating how. An average or selected occasion changes what is retained. Use a summary only when it matches the question, and define it clearly.
- Reshaping when there are multiple values for a unit-column combination. If one student has several quiz scores, a single “Quiz score” cell cannot preserve all of them without an additional rule or a different row definition.
- Treating a convenient layout as proof of a suitable analysis. A clean one-row-per-unit table is helpful, but does not by itself justify a statistical model or its assumptions.
Check Your Understanding
For each question, identify the intended unit and say whether one row per person is appropriate.
- A table records one blood-pressure measurement for each of 80 patients at a single scheduled visit. What should one row represent?
- A table records blood pressure for each patient at three scheduled visits. What would each row represent in a layout designed to preserve every measurement occasion?
- A hypothetical file has two rows per student, one for a reading test and one for a mathematics test. The question concerns both scores for each student. What reshaped layout would be useful, and how many rows should it have if there are 25 students?
- A clinic wants to describe waiting time for each appointment, and some patients have several appointments. Should each patient necessarily appear only once? Explain.
- Why does averaging two measurements before making one row per person change the information represented in the table?