next up previous
Next: Example 3 Up: Using read.table Previous: Example 1

Example 2

In the second example, the data file already includes the variable names.
Dose                    Water           Relief
.1                      10              7
.2                      10              15
.3                      10              19
...
Unless instructed otherwise, S-PLUS will read the data into a 13-row, 3-column matrix with columns labelled V1, V2, and V3. The first observation in the V1 column would be ``Dose'', the first in the V2 column would be ``Water'', and the first in the V3 column would be ``Relief''. That isn't what we want, instead we want it to treat the first row (the ``header'') as variable names.

> ex2 <- read.table("example2", header=T)

The ``header=T'' argument tells S-PLUS that ``example 2'' has a header (T stands for ``true''). The resulting data frame is the same as the one at the end of example 1.



Brian Junker 2002-08-26