1998-01-16 (Week 2)

UNIX Prerequisites

Log on to an X-terminal, set up screen and printer graphics, learn the vi editor, learn basic file management commands (ls, mkdir, rmdir, cd, rm, etc.), learn how to move files between different computers.

The least you need to know about the vi Editor...

Arrow Keys

Move the cursor

a

Append text to the right of the cursor

i

Insert text to the left of the cursor

<ESC>

Terminate insert or append sequences

r

Replace current character

x

Delete current character

dd

Delete current line

/string

Find next forward occurrence of string

?string

Find next backward occurrence of string

n

Find next forward occurrence of current search string

N

Find next backward occurrence of current search string

:

Switch to command mode.

Commands: wq (write and quit), q! (quit without writing), etc.

<CR>

In insert or append: start a new line
In command mode: enter the command


Creating S Functions (Spector p. 117)

> plot3d <- vi(function(){}) # Works on hydra, data
 
> fix(plot3d) # Works only on data
 

Either of the above functions opens a function template in the vi editor and, if you exit the editor with :wq, writes the result to an S object called plot3d. If plot3d exists already, you can edit it with plot3d<- vi(plot3d) or fix(plot3d). If a function had a syntax error, you can use fix() to reedit it on data.

You should use functions whenever your S code is longer than a single line, to avoid retyping if you make an error.


Recoding and Tabulating the Ear Data from Rosner

Get the MINITAB Portable file ear.mtp from the data disk that comes with Rosner. Open it in MINITAB, save it as text, ftp it to data or hydra, use read.table to create a data frame called ear. The first 128 children had a single infected ear. The remaining children had 2 infected ears. Use S to create a new data frame called ear2 where each child has just one row with the following variables: id, clear2, antibio, age, num.ears, where clear2 is the number of ears cleared (0 or 1 for unilateral infections, 0, 1, or 2 for bilateral infections) and num.ears is the number of ears originally infected (1 for unilateral, 2 for bilateral).

Create a 4-way cross tabulation (clear2 by antibio by age by num.ears). Which antibiotic is more effective? Does that depend on age? Are the 2 ears of a bilateral infection statistically independent?

See the S2MA3 notes for suggestions on how to do this with BASIC. I expect you to use S.


Effects of Effluent on the Kapuskasing River: Getting Started

You have to know a bit about how fish grow and how rings on bony parts can be used to back-calculate growth. A good reference is

Summerfelt, R.C. & Hall, G.E. [Eds.] Age and Growth of Fish, Iowa State, 1987.

The space between two rings on a scale or on a cross-section of a bony part (otolith, operculum, fin ray, etc.) indicates how much the fish grew in the year the ring was laid down. You can expect growth to depend on the age of the fish at that time, the growing conditions that year, and the environmental conditions (including the presence or absence of effluent) in the part of the river where the fish was living.

Get the data file operc.txt as a text file from the SSC Web Site. The file seems to have been saved from SYSTAT; you need to prepare if for S. Put it in a word processor or text editor and change the . missing value code to NA throughout. Also, for convenience, you might like to rename the variables using lower case and omitting the $ after the character variable names. Send the file to data or hydra by ftp.

Use read.table to read the file into a data frame called operc.

EDA means "Exploratory Data Analysis", a search for patterns and relationships. This is different from tests of hypothesis, which are used to confirm hypothesized relationships. Why is it not right to use the same data for EDA and for confirmatory tests? What can we do about this here, where there is only one data set?

Click here to see how I started exploring the data.


Back to S4P03
Last Modified 1998-01-18