﻿ VisualStat® Examples - Stack Columns

Software to Simplify Statistical Practice ...

## Stack Columns

Use Stack Columns to move data from two or more columns to one longer column within your current datasheet or to a new datasheet.

When you stack columns, you can also create a column of groups, or identifier codes, that indicate which column an observation came from. You can use these labels to:

·create graphs in which data points display differently depending on which group they are from

·unstack the columns

In the illustration below, 5 varieties of peas are tested by cooperatives to determine which is best suited for production. A field was divided into 20 plots, with each variety of peas planted in four plots. The data in the B column are stacked below the data in the A column and on top of the data in the C column in the new Group Column. The data in columns D and E are at the last position.

 Variety of Pea A B C D E 26.2 29.2 29.1 21.3 20.1 24.3 28.1 30.8 22.4 19.3 21.8 27.3 33.9 24.3 19.9 28.1 31.2 32.8 21.8 22.1

 Variety of Pea Value Group Column 26.2 A 24.3 A 21.8 A 28.1 A 29.2 B 28.1 B 27.3 B 31.2 B 29.1 C 30.8 C 33.9 C 32.8 C 21.3 D 22.4 D 24.3 D 21.8 D 20.1 E 19.3 E 19.9 E 22.1 E

The values in the Group-Column are labels that identify which column the value came from.

It is usually a good idea to store a subscript column so you can identify the data point associated with each group. For example, in this case, you could analyze the data in Value, using the data in Group-Column as a factor or a grouping variable.

#### Data

Data can be numeric, text, or any type of data.
Columns are not required to be the same length.

#### Example

Suppose we measure the thickness of plaque (mm) in the carotid artery of 10 randomly selected patients with mild atherosclerotic disease. Two measurements are taken, thickness before treatment with Vitamin E (baseline) and after two years of taking Vitamin E daily.

1. Open the DataBook compare.vstz
open this data file via the Help / Open Examples menu; it is in the Sample Data
2. Select the sheet plaque
3. Choose the tab Data, the group Variable and the command Stack
4. In Variable to Stack, select Before and After
5. In Stacked Data, enter Measure
6. In Group Variable, enter Thickness
7. Click OK

DataSheet window output

 Measure Thickness 0.6600 Before 0.7200 Before 0.8500 Before 0.6200 Before 0.5900 Before 0.6300 Before 0.6400 Before 0.7000 Before 0.7300 Before 0.6800 Before 0.6000 After 0.6500 After 0.7900 After 0.6300 After 0.5400 After 0.5500 After 0.6200 After 0.6700 After 0.6800 After 0.6400 After