-
Notifications
You must be signed in to change notification settings - Fork 0
/
presentation.Rmd
109 lines (82 loc) · 2.87 KB
/
presentation.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
title: "presenation"
author: "Breanna Wenck"
date: "12/13/2020"
output:
html_document: default
word_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
```
```{r load_data}
library(tidyverse)
library(tigris)
library(na.tools)
library(lubridate)
library(viridis)
library(leaflet)
library(readxl)
library(stringr)
library(knitr)
library(kableExtra)
LC_covid <- read_csv("raw_data/LC-COVID-casesdata.csv")
covid_deaths <- read_csv("raw_data/covid_deaths.csv")
```
```{r}
### Make all city names in title format to join data sets
LC_covid <- LC_covid %>%
mutate(City = str_to_title(City))
total_covid_per_city <- LC_covid %>%
group_by(City) %>%
count()
```
```{r}
### Create vectors of gps coordinates of cities from information collected from
### the internet
Lat <- c(40.625679, 40.284667, 40.431269, 40.377117, 40.559167,
40.453740, 40.336944, 40.633808, 40.794319, 40.404789, 40.487171,
40.807820, 40.529718, 40.702324, 40.477222)
Lon <- c( -105.171089, -104.965504, -105.339661, -105.525514,
-105.078056, -105.448837, -104.912222, -105.148819, -105.216579,
-105.085868, -105.210056,-105.578641, -104.981654,
-105.005497, -104.911944)
City <- c("Bellvue", "Berthoud", "Drake", "Estes Park",
"Fort Collins", "Glen Haven", "Johnstown", "Laporte", "Livermore",
"Loveland", "Masonville", "Red Feather Lakes", "Timnath",
"Wellington", "Windsor")
```
```{r}
### Combine the vectors into a data frame and then join the data sets so cities
### have coordinates associated with them for mapping and remove NA values
larimer_gps <- data.frame(City, Lat, Lon)
total_covid <- full_join(total_covid_per_city, larimer_gps, by = "City") %>%
na.rm()
LC_covid_gps <- full_join(larimer_gps, LC_covid, by = "City") %>%
na.rm()
LC_covid_gps <- full_join(total_covid, LC_covid_gps, by = "City")
LC_covid_gps <- LC_covid_gps %>%
mutate(ReportedDate = mdy(ReportedDate))
total_city_count <- LC_covid_gps %>%
group_by(City) %>%
summarize(total_count = n(),
mean_age = mean(Age, na.rm = TRUE),
.groups = "drop")
```
```{r}
covid_deaths <- full_join(larimer_gps, covid_deaths,
by = list(x = "City", y = "city")) %>% na.rm()
covid_deaths_total <- covid_deaths %>%
group_by(City) %>%
count()
mean_age_deaths <- covid_deaths %>%
group_by(City) %>%
summarize(mean_age_death = mean(age), .groups = "drop")
mean_age_deaths <- full_join(mean_age_deaths, covid_deaths_total, by = "City")
covid_table <- full_join(total_city_count, mean_age_deaths, by = "City")
kable(covid_table, digits = 2,
col.names = c("City", "Cases", "Mean age", "Mean age of death",
"Num of deaths"),
caption = "Cases, deaths, and average age per city", align = "c") %>%
kable_paper()
```