August 27, 2008

嚜澠ntroduction to R

and

Exploratory Data Analysis

August 27, 2008

Introduction to RandExploratory Data Analysis 每 p.1/18

Agent Orange Case Study (SS Ch 3)

Dioxin concentrations in parts per trillion (ppt) for 646

Vietnam veterans and 97 veterans who did not serve in

Vietnam.

sample (nonrandom) of Vietnam vets who served

during 1967-1968

sample (nonrandom) of vets who served in the US

and Germany between 1965-1971

Dioxin measurements taken in 1987

Observational Study

Introduction to RandExploratory Data Analysis 每 p.2/18

Startup R

Unix command line: R

Windows/Mac double-click R GUI

Under emacs/ESS enter M-x R

Introduction to RandExploratory Data Analysis 每 p.3/18

Creating a Dataframe in R

> vets = read.table("case0302.csv", header=T,

sep=",")

> names(vets)

[1] "DIOXIN" "VETERAN"

Notes:

1. header=T tells R that the first line of the file contains

variable names

2. sep="," tells R that columns of data are separated

by a comma (the csv format)

3. the names function extracts the names of variables in

a dataframe

Introduction to RandExploratory Data Analysis 每 p.4/18

Reading Data

read.csv Comma separated variable format

read.fwf Fixed width format

read.delim Tab delimited files

See help(read.table) for options, such as setting

character for NAs, column separators, skipping lines, etc

See also scan() for reading in large files

Introduction to RandExploratory Data Analysis 每 p.5/18

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download