
i
i
“K23166” — 2015/1/28 — 9:35 — page 21 — #47
i
i
i
i
i
i
2.3. MERGING, COMBINING, AND SUBSETTING DATASETS 21
2.3.7 Convert from wide to long (tall) format
Example: 7.10.9
Data are often found in a different shape than that required for analysis. One example of
this is commonly found in longitudinal measures studies. In this setting it is convenient to
store the data in a wide or multivariate format with one line per observation, containing
typically subject-invariant factors (e.g., gender), as well as a column for each repeated
outcome. An example is given below.
id female inc80 inc81 inc82
1 0 5000 5500 6000
2 1 2000 2200 3300
3 0 3000 2000 1000
Here, the income ...