-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquiz.Rmd
188 lines (114 loc) · 3.61 KB
/
quiz.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
---
title: 'Trends in health indicators: how well do you know them?'
author: "Julian Flowers"
date: "10/08/2017"
output:
ioslides_presentation: default
slidy_presentation: default
---
```{r setup, include=FALSE, cache=TRUE}
knitr::opts_chunk$set(cache = TRUE, echo = FALSE, warning = FALSE, message = FALSE)
```
```{r libraries, cache=TRUE, echo=FALSE, warning=FALSE, message=FALSE}
library(shinysense)
library(fingertipsR)
library(tidyverse)
library(stringr)
indids <- c(91183, 92432, 91361, 90360, 92196, 40601, 20401, 11202) ## select ids
mydata <- fingertips_data(IndicatorID = indids) ## download data
dataset <- filter(mydata, AreaName == "England") %>%
mutate(date = as.Date(paste(str_sub(TimeperiodSortable, 1, 4), "01", "01", sep = "-"))) %>%
mutate_if(is.factor, as.character) %>%
select(IndicatorID, date, Value, Sex, AreaName, IndicatorName)
```
```{r echo = FALSE}
## Function to draw charts
draw_chart <- function(df, i = 6){
## i = start point ie number of points already drawn
endDate <- df$date[i]
drawr_widget(
data = df,
draw_start = endDate,
x_key = "date",
y_key = "value",
y_min = min(df$value) * .8,
y_max = 1.2 *max(df$value),
width="100%"
)
}
```
## Test your knowledge of health data in England
- Take the quiz [here](http://rpubs.com/jflowers/299049).
- The following slides shows the trend in some key indicators of health in England
- The data comes from the Public Health Outcomes Framework
- The chart are incomplete
- Using your mouse, draw where *you* think the trend is
- The true trend will be revealed when you get to the end
- How did you do?
## `r dataset %>% filter(IndicatorID == 91183) %>% select(IndicatorName) %>% distinct()`
```{r smoking 15, echo = FALSE}
library(tidyverse)
library(stringr)
library(shinysense)
id <- 91183
draw <- dataset %>%
filter(IndicatorID == id, Sex == "Persons") %>%
select(date, value = Value)
draw_chart(draw)
```
## `r dataset %>% filter(IndicatorID == 92432) %>% select(IndicatorName) %>% distinct()`
```{r drug deaths, echo=FALSE}
id <- 92432
draw <- dataset %>%
filter(IndicatorID == id, Sex == "Persons") %>%
select(date, value = Value)
draw_chart(draw)
```
## `r dataset %>% filter(IndicatorID == 91361) %>% select(IndicatorName) %>% distinct()`
```{r incidence of tb, echo=FALSE}
id <- 91361
draw <- dataset %>%
filter(IndicatorID == id, Sex == "Persons") %>%
select(date, value = Value)
draw_chart(draw)
```
## `r dataset %>% filter(IndicatorID == 90360) %>% select(IndicatorName) %>% distinct()`
```{r winter deaths, echo=FALSE}
id <- 90360
draw <- dataset %>%
filter(IndicatorID == id, Sex == "Persons") %>%
select(date, value = Value)
draw_chart(draw)
```
## `r dataset %>% filter(IndicatorID == 92196) %>% select(IndicatorName) %>% distinct()`
```{r echo=FALSE}
id <- 92196
draw <- dataset %>%
filter(IndicatorID == id, Sex == "Persons") %>%
select(date, value = Value)
draw_chart(draw)
```
## `r dataset %>% filter(IndicatorID == 40601) %>% select(IndicatorName) %>% distinct()`
```{r echo=FALSE}
id <- 40601
draw <- dataset %>%
filter(IndicatorID == id, Sex == "Persons") %>%
select(date, value = Value)
draw_chart(draw)
```
## `r dataset %>% filter(IndicatorID == 20401) %>% select(IndicatorName) %>% distinct()`
```{r echo=FALSE}
id <- 20401
draw <- dataset %>%
filter(IndicatorID == id) %>%
select(date, value = Value)
draw_chart(draw)
```
## `r dataset %>% filter(IndicatorID == 11202) %>% select(IndicatorName) %>% distinct()`
```{r echo=FALSE}
id <- 11202
draw <- dataset %>%
filter(IndicatorID == id) %>%
select(date, value = Value)
draw_chart(draw, 3)
```