---
title: "R Notebook"
output:
  pdf_document: default
  html_notebook: default
---

```{r}
my_sample <- c(180, 157, 185, 140, 150, 180)
mu_0 <- 150
```
$$H_0: population.mean = \mu_0$$
$$H_1: population.mean > \mu_0$$
## Problem
Is it true that population mean > $\mu_0$.
### Part 1.
Find T-statistics.
$$t=\frac{\bar x - \mu_0}{sample.std.dev}  
\sqrt{n}$$
```{r}
sd(c(1, 2, 3))
```
```{r}
xbar <- mean(my_sample)
sample.std.dev <- sd(my_sample)
t <- (xbar - mu_0) / (sample.std.dev) * sqrt(length(my_sample))
t
```

```{r}
my_sample <- c(180, 157, 185, 140, 150, 180)
mu_0 <- 150
t.test(my_sample, 
       mu=mu_0, 
       alternative = "less")
```

```{r}
dat <- read.csv("https://bit.ly/37aTkWv")
```

```{r}
head(dat)
```

```{r}
dat$word
```

```{r}
v <- c(1, 2, -3, 2, -5, 3, 4, 10)
```

```{r}
v[v > 0]
```
```{r}
v > 0
```

```{r}
v <- c(1, 2, -3, 2, -5, 3, 4, 10)
v[c(FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE)]
```

```{r}
v[2:length(v)] > v[0:(length(v)-1)]
```
```{r}
dat[2,]
```

```{r}
dat[dat$word == "kokk","speaker"]
```

## Problem
Select rows from `dat` for which *aspiration* is `yes` and plot histogram of variable time for these rows.

Is it true that population mean for time (for aspirated vowel) is larger than 200? (Use `t.test`.)

```{r}
time_asp <- dat[dat$aspiration == "yes", "time"]
hist(time_asp, breaks=c(0, 200, 300, 400, 500, 900))
t.test(time_asp, alternative = "greater",
       mu=200)
```


```{r}
2.2e-4
```

