---
title: "Class 13"
author: "Andres Aravena, PhD"
date: "22/11/2016"
output: 
  html_document: 
    self_contained: no
---

# Reading data
```{r}
birth <- read.table("http://anaraven.github.io/static/birth.txt", header=TRUE)
summary(birth)
```

# Number of cases
```{r}
nrow(birth)
```

# Initial graphics
```{r}
plot(head ~ age, data = birth)
plot(head ~ age, data = birth, subset = sex=="F")
plot(head ~ age, data = birth, subset = sex=="M")
```

# Corrected graphics
```{r}
plot(head ~ age, data = birth)
plot(head ~ age, data = birth, subset = sex=="F", xlim=range(age), ylim=range(head))
plot(head ~ age, data = birth, subset = sex=="M", xlim=range(age), ylim=range(head))
```

# Final graphics
```{r}
plot(head ~ age, data = birth, main="Baby head size v/s Mom's age", xlab="Age [years]", ylab="Head cicumference [cm]")
plot(head ~ age, data = birth, subset = sex=="F", xlim=range(age), ylim=range(head), main="Baby head size v/s Mom's age", xlab="Age [years]", ylab="Head cicumference [cm]", sub="Girls")
plot(head ~ age, data = birth, subset = sex=="M", xlim=range(age), ylim=range(head), main="Baby head size v/s Mom's age", xlab="Age [years]", ylab="Head cicumference [cm]", sub="Boys")
```

## Different colors or shapes
```{r}
plot(head ~ age, data = birth, main="Baby head size v/s Mom's age", xlab="Age [years]", ylab="Head cicumference [cm]", col=sex)

plot(jitter(head) ~ jitter(age), data = birth, main="Baby head size v/s Mom's age", xlab="Age [years]", ylab="Head cicumference [cm]", col=sex)
```
