---
title: "MATH 542 | Lab 3"
author: "Saket Choudhary"
date: "February 13, 2016"
output: pdf_document
---

## Problem 1

### Problem 1a
```{r}
birdful.data <- read.csv('BirdFlu.csv', header=T)
cases.2003 <- sum(birdful.data$X2003.cases)
```
Total cases in 2003: `r cases.2003`

### Problem 1b
```{r}
cases.2003.2005 <- sum(birdful.data$X2003.cases)+sum(birdful.data$X2005.cases)
```
Total cases in 2003 and 2005: `r cases.2003.2005`

### Problem 1c

```{r}
total.deaths <- rowSums(birdful.data[,-1])
max.which <- which.max(total.deaths)
min.which <- which.min(total.deaths)
max.country <- birdful.data$Country[max.which]
min.country <- birdful.data$Country[min.which]
```

Country with most cases: `r max.country`

Country with least cases: `r min.country`

### Problem 1d

```{r kable}
birdful.data['total'] <- total.deaths
library(knitr)
kable(subset(birdful.data, select=c('Country', 'total')))
```

Total number of cases per year

```{r}
column.sum <- colSums(birdful.data[,-1])
#t(kable(rbind(t(colnames(birdful.data)[2:13]), t(column.sum[1:12]) )))
kable(column.sum[1:12])
```

## Problem 2

```{r}
isit <- read.csv('ISIT.txt', sep = '\t')
station1.data <- subset(isit, Station=="1")
nobs1 <- nrow(station1.data)
sample1.depth <- station1.data$SampleDepth
```

### Problem 2a
Number of observations in station 1: `r nobs1`

Summary of station 1:
```{r}
summary(station1.data)
```

Mean median etc of `Sample.Depth`:
```{r}
summary(sample1.depth)
```
Mean: `r mean(sample1.depth, na.rm=T)`

Median: `r median(sample1.depth, na.rm=T)`

Minimum: `r min(sample1.depth, na.rm=T)`

Maximum: `r max(sample1.depth, na.rm=T)`



### Problem 2b

## Problem 2b.1
```{r}
data2002 <- subset(isit, Year=2002)
kable(data2002)
```

## Problem 2b.2
```{r}
april.data <-  subset(isit, Month==4)
kable(april.data)
```

## Problem 2b.3
```{r}
depths <- subset(isit, SampleDepth>2000)
kable(depths)
```

### Problem 2c
```{r}
april.data.2002 <- subset(depths, Month==4)
kable(april.data.2002)
```
```