---
title: "Tidy Quiz"
author: "K Arnold"
date: "2022-10-18"
output: html_document
---

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

```{r}
data <- readxl::read_excel("data/tidy-data.xlsx")
kable(data)
```

```{r}
data %>% mutate(percap = Cases / Population)
data %>% 
  ggplot(aes(x = Year, y = Cases, color = Country)) + geom_line()
```


```{r}
overtidy <- data %>% 
  pivot_longer(c(Cases, Population))
kable(overtidy)
```


```{r}
widest <- overtidy  %>% 
  pivot_wider(Country, names_from = c("name", "Year"), names_vary = "slowest", names_sort = TRUE)#, names_sep = " in ")
kable(widest)
```

```{r}
widest %>% mutate(case_change = Cases_2000 - Cases_1999)
```

