```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## What you guys thought...


Some of you got very close. Someone was even just a few days away from being exactly right. Below is some summary statistics and some graphs of the guesses.

<br>

```{r, echo = FALSE, message = FALSE, warning = FALSE}
library(tidyverse)
guesses <- tibble::tribble(
  ~age, ~own_age,
  32, 37,
  35.49, 31,
  31, 25,
  29.2, NA,
  32, 25,
  28.5, NA,
  30.5, 23.25,
  31, NA,
  31, 33,
  34, 31,
  29.1, NA,
  34, 29,
  32, 25,
  30, 23,
  34, 36,
  32.6, 29,
  26.5, 38,
  27.8, NA,
  32.4, 26,
  33, 30
)


guesses %>%
  summarize(mean = mean(age),
            sd = sd(age),
            median = median(age),
            min = min(age),
            max = max(age)) %>%
  pander::pander(caption = "Table 1. Summary Statistics of the Guesses")
```

<br>

```{r}
p1 <- ggplot(guesses, aes(x = age)) +
  geom_histogram(bins = 8,
                 alpha = .5,
                 fill = "chartreuse3",
                 color = "chartreuse3") +
  geom_dotplot(binwidth = 1.05,
               fill = "dodgerblue3",
               color = "dodgerblue4",
               alpha = .8) +
  geom_rug(color = "dodgerblue4") +
  theme_minimal() +
  labs(y = "Count", 
       x = "Guess of Age (in Years)") +
  geom_vline(xintercept = 30.2,
           color = "coral2") +
  annotate("text", x = 30.1, y = 4.5, hjust = 1,
           label = "True Age",
           color = "coral2")
p1
```

Let's change the x-axis. Let's say we wanted to see if you guessed close based on working ages (20 - 65 years old).

```{r}
p1 +
  coord_cartesian(xlim = c(20,65))
```

## Relationship between Your Guess and Your Age

```{r}
guesses %>%
  lm(age ~ own_age,
     data = .) %>%
  summary()
```

```{r}
guesses %>%
  ggplot(aes(own_age, age)) +
    geom_point() +
    geom_smooth(method = "lm") +
    labs(x = "Your Own Age",
         y = "Your Guess")
```



## Relationship between How Wrong Your Guess Was and Your Age

```{r}
guesses %>%
  mutate(wrongness = abs(age - 30)) %>%
  lm(wrongness ~ own_age, 
     data = .) %>%
  summary()
```

```{r}
guesses %>%
  mutate(wrongness = abs(age - 30)) %>%
  ggplot(aes(own_age, wrongness)) +
    geom_point() +
    geom_smooth(method = "lm") +
    labs(x = "Your Own Age",
         y = "Your Guess")
```
