-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiabetes_ojs.qmd
90 lines (64 loc) · 1.43 KB
/
diabetes_ojs.qmd
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
---
title: "diabetes_ojs"
format: dashboard
---
```{r}
library(tidyverse)
library(zoo)
```
```{r}
bgts_cgm_geog_icb <- readRDS("/Users/juliancollins/Repos/ShinyPractice/bgts_cgm/bgts_cgm_geog_icb.Rds")
bgts_cgm_geog_icb <- bgts_cgm_geog_icb |> select(-year_month2)
bgts_cgm_geog_icb <- bgts_cgm_geog_icb |>
mutate(year_month4 = ymd(paste0(year_month3, "01")))
bgts_cgm_geog_icb2 <- bgts_cgm_geog_icb |>
group_by(icb, year_month3) |>
summarise(net_ingredient_cost = sum(net_ingredient_cost)) |>
ungroup() |>
distinct()
#bgts_cgm_geog_icb$year_month2 <- as.yearmon(as.character(bgts_cgm_geog_icb$year_month3), "%Y%m")
ojs_define(bgts_ojs = bgts_cgm_geog_icb2)
```
```{ojs}
//| output: false
bgts = transpose(bgts_ojs)
```
```{ojs}
//| panel: sidebar
viewof icb_dropdown = Inputs.select(
bgts.map(d => d.icb),
{
value: "Black Country",
label: "Select ICB:",
unique: true
}
)
```
```{ojs}
Plot.plot({
y: {
grid: true,
label: "something"
},
marks: [
Plot.ruleY([0]),
Plot.lineY(bgts, {
filter: (d) => d.icb == icb_dropdown,
x: "year_month3",
y: "net_ingredient_cost",
stroke: "icb",
tip: "x",
marker: true
}),
Plot.text(bgts, Plot.selectLast({
filter: (d) => d.icb == icb_dropdown,
x: "year_month3",
y: "net_ingredient_cost",
z: "icb",
text: "icb",
textAnchor: "end",
dx: 3}))
],
marginLeft: 100
})
```