-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdrawr.Rmd
71 lines (53 loc) · 1.3 KB
/
drawr.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
---
title: "R Notebook"
output: html_notebook
editor_options:
chunk_output_type: inline
---
# Using `shinysense`
Based on <http://livefreeordichotomize.com/2017/07/27/new-and-improved-draw-charts-in-shinysense/>
```{r}
devtools::install_github('nstrayer/shinysense')
library(tidyverse)
library(shinysense)
library(fingertipsR)
library(stringr)
```
```{r}
dates <- seq(as.Date("2017/1/1"), as.Date("2017/07/22"), "weeks")
numWeeks <- length(dates)
endDate <- dates[15]
timeData <- data_frame(
date = dates,
value = 50 + (1:numWeeks) * cos((1:numWeeks) / 6) + rnorm(numWeeks)
)
drawr_widget(
data = timeData,
draw_start = endDate,
x_key = "date",
y_key = "value",
width="100%"
)
```
## Try some Fingerips data
AMR data might work
```{r}
area_types()
data <- fingertips_data(IndicatorID = 92377, AreaTypeID = 153 ) %>%
mutate_if(is.factor, as.character) %>%
select(AreaName, Timeperiod, Value)
data <- data %>%
mutate(date = lubridate::ymd(paste(str_sub(Timeperiod, -4), str_sub(Timeperiod,1,3), "01", sep = "-")))
unique(data$AreaName)
test_data <- data %>%
filter(AreaName == "NHS Bedfordshire CCG") %>%
select(date = date, value = Value)
endDate <- test_data$date[15]
drawr_widget(
data = test_data,
draw_start = endDate,
x_key = "date",
y_key = "value",
width="100%"
)
```