-
Notifications
You must be signed in to change notification settings - Fork 2
/
Backupvital.txt
133 lines (81 loc) · 3.57 KB
/
Backupvital.txt
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
title: "Opoid-Related Deaths in New York State"
author: "Anuwat Pengput"
subtitle: "Spatial Epidemiological Analysis and Risk Factors of Opoid-Related Deathsin New York"
---
# Introduction
Opioid analgesics are pain relievers derived from opium or have an opium-like activity. There are no better drugs than opioids for treating severe pain and suffering, however, opioids are the main drugs associated with overdose deaths. Opioid prescription rates have increased almost threefold associated with an increase of opioid related overdoses and deaths in the last 15 years. New York has been greatly impacted by the opioid epidemic. The rate of deaths related to any opioid in New York has increased by 210% from 2010 to 2016. The opioid overdose death rate in the overall state was 18 deaths per 100,000 residents, which was higher than many states in the United States.
# Materials and methods
Narrative and most code will go here. Describe what you are doing and show how to do it (with code).
You can do bullets like this:
* The first most important thing
* The second most important thing
* The third most important thing
You can do numbers like this:
1. The first most important thing
2. The second most important thing
3. The third most important thing
See [http://rmarkdown.rstudio.com/](http://rmarkdown.rstudio.com/) for all the amazing things you can do.
Here's my first code chunk.
```{r}
1+2
```
Load any required packages in a code chunk (you may need to install some packages):
```{r message=FALSE, warning=FALSE, include=FALSE}
library(tidycensus)
library(leaflet)
library(mapview)
library(tidyr)
library(plotly)
knitr::opts_chunk$set(cache=TRUE) # cache the results for quick compiling
```
## Download and clean all required data
```{r echo=TRUE}
NY <- get_acs(geography = "county",
variables = c(medincome = "B19013_001"),
state = "NY", geometry = TRUE, cache_table=T)
## Opioid Deaths
vital <- read.csv('data/vital.csv')
ny_sep <- NY %>%
separate(NAME, c("County"))
ny_sep[45,"County"] <- "St Lawrence"
vital_2017 <- vital %>%
filter(Year == 2017)
vital_ny_2017 <- ny_sep %>%
left_join(vital_2017, by = "County")
```
```{r echo=TRUE, fig.height=10, fig.width=8}
g <- ggplot (data = vital) +
geom_line(aes(x = Year, y = Opioid.Poisoning.Deaths, group = County, col = County)) +
geom_point(aes(x = Year, y = Opioid.Poisoning.Deaths, group = County, col = County, size = Opioid.Poisoning.Deaths)) +
geom_smooth(aes(x = Year, y = Opioid.Poisoning.Deaths)) +
theme_bw() +
labs (title = "Annual Number of Opioid Related Deaths in New York 2003-2017", x = "Year", y= "Number of Opioid Related Deaths")
ggplotly (g, tooltip = c("County", "Opioid.Poisoning.Deaths", "Year"))
```
```{r echo=TRUE}
fit=lm(Opioid.Poisoning.Deaths ~ estimate, data = vital_ny_2017)
summary(fit)
ggplot(vital_ny_2017,aes(y=Opioid.Poisoning.Deaths,x=estimate)) +
geom_point() +
geom_smooth(method="lm")
```
# Results
Show tables, plots, etc. and describe them.
```{r echo=TRUE, fig.height=10, fig.width=8}
ggplotly (g, tooltip = c("County", "Opioid.Poisoning.Deaths", "Year"))
```
```{r echo=TRUE, fig.height=10, fig.width=8}
mapview(vital_ny_2017, zcol = "Opioid.Poisoning.Deaths", legend = TRUE, alpha = 0.5)
```
```{r echo=TRUE, warning=FALSE}
ggplot(vital_ny_2017,aes(y=Opioid.Poisoning.Deaths,x=estimate)) +
geom_point() +
geom_smooth(method="lm")
```
```{r echo=TRUE}
ggPredict(fit,se=TRUE,interactive=TRUE)
```
# Conclusions
What have you learned? Are there any broader implications?
# References