Alice’s heart-rate changes
The change in heart rate after a caffeinated diet cola was
17,\;22,\;21,\;16,\;6,\;-2,\;27,\;15,\;16,\;20
and after a decaffeinated diet cola was
4,\;10,\;7,\;-9,\;5,\;4,\;5,\;7,\;6,\;12.
Write the measurements as a table with one row per subject and say which column is the response and which is the treatment.
Worked answer (click to show)
In standard form each of the 20 subjects is one row, with the change in heart rate in one column and the drink in another:
| Subject | pb | Caffeine |
|---|---|---|
| 1 | 17 | Yes |
| 2 | 22 | Yes |
| ⋮ | ⋮ | ⋮ |
| 10 | 20 | Yes |
| 11 | 4 | No |
| ⋮ | ⋮ | ⋮ |
| 20 | 12 | No |
The response is pb, the change in heart rate, a quantitative variable. The treatment is Caffeine, a factor with two levels. Saved as alice.csv, the table is read with alice <- read.csv("alice.csv"), and alice$Caffeine <- factor(alice$Caffeine) makes sure R treats the drink as categorical.