Format of data sets in stats1.RData

Data sets in this workspace are stored in one of 3 different R formats.

1. Single samples of data are stored as numeric vectors, e.g. iridium

2. Collections of two or more associated variables, that may be vectors of
different length, are stored as lists, e.g. secretaries

3. A data set consisting of several variables, measured on the same
individual or units, is stored as a data.frame; in this case the variables
are necessarily of the same length, e.g. kwh or pig

A quick way to see which of these 3 cases applies is to use the str()
function.

In cases 2 and 3, you can refer to individual variables by following the data
set name with $ and the variable name. If you attach() the data set you can
refer to the individual variables directly.

Examples

> iridium
 [1] 136.6 145.2 151.5 162.7 159.1 159.8 160.8 173.9 160.1 160.4 161.1 160.6
[13] 160.2 159.5 160.3 159.2 159.3 159.6 160.0 160.2 160.1 160.0 159.7 159.5
[25] 159.5 159.6 159.5

> secretaries
$private
[1] 12.1 13.4 11.3 10.6  9.7 12.5  9.6 13.6 11.2

$public
 [1]  9.3  8.5  8.2 13.1  8.8 11.9 10.1  9.8 12.2 10.4

> kwh
   before after
1     940   900
2    1370  1230
3    1030  1060
4    2030  2100
5    1540  1250
6    2300  2200
7    1800  1820
8     910   900
9     640   630
10   1200  1110

> pig
  littersize  wt
1          1 1.6
2          3 1.5
3          5 1.5
4          8 1.3
5          8 1.4
6          9 1.2
7         10 1.1

> str(iridium)
 num [1:27] 137 145 152 163 159 ...

> str(secretaries)
List of 2
 $ private: num [1:9] 12.1 13.4 11.3 10.6 9.7 12.5 9.6 13.6 11.2
 $ public : num [1:10] 9.3 8.5 8.2 13.1 8.8 11.9 10.1 9.8 12.2 10.4

> str(kwh)
'data.frame':   10 obs. of  2 variables:
 $ before: num  940 1370 1030 2030 1540 2300 1800 910 640 1200
 $ after : num  900 1230 1060 2100 1250 2200 1820 900 630 1110

> secretaries$private
[1] 12.1 13.4 11.3 10.6  9.7 12.5  9.6 13.6 11.2

> kwh$after
 [1]  900 1230 1060 2100 1250 2200 1820  900  630 1110

> attach(pig)
> wt
[1] 1.6 1.5 1.5 1.3 1.4 1.2 1.1