-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathType of birth small multiples.R
executable file
·89 lines (68 loc) · 2.66 KB
/
Type of birth small multiples.R
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
# a) data ----
# map input$tob to the values in measure_cat to enable filtering of the data frame
observeEvent(input$tob, Selected$Measure_cat <- input$tob)
type_of_birth_small_multiples_data <- reactive({
# selects data
req(input$organisation)
data <- type_of_birth_data %>%
filter(hbtype == Selected$HBType &
measure_cat == Selected$Measure_cat) %>%
mutate(hbname2 = if_else(grepl("planned", measure_cat) & hbname == "NHS Borders",
"NHS Borders*",
hbname),
hbname2 = factor(hbname2,
levels = HBnames),
mytext = paste0(hbname,
": ",
measure_cat,
"<br>",
"Quarter: ",
quarter_label,
"<br>",
"Percentage of births",
": ",
format(measure_value,
digits = 1,
nsmall = 1),
"%"),
date = quarter_label,
hbgroup = factor(if_else(hbname %in% island_names, "island", "mainland"),
levels = c("mainland", "island"), ordered = TRUE)
) %>%
group_by(hbgroup, hbtype) %>%
mutate(y_max = max(measure_value)
) %>%
ungroup()
if (is.null(data))
{
return()
}
else {
data
}
})
# b) chart ----
output$type_of_birth_small_multiples <- renderPlotly({
subplot_mainland_island_small_multiples(
plotdata = type_of_birth_small_multiples_data()
)
})
# c) chart title ----
output$type_of_birth_small_multiples_title <- renderText({
paste0("Board of ",
str_to_sentence(input$organisation)
)
})
output$type_of_birth_small_multiples_sub_title <- renderUI({
title_text <- case_match(Selected$Measure_cat,
"assisted vaginal births" ~ HTML(paste0("Percentage of singleton live births at any gestation that were ",
input$tob,
" (includes forceps, ventouse and vaginal breech births)")),
"all caesarean births" ~ HTML("Percentage of singleton live births at any gestation that were
caesarean births"),
.default = HTML(paste0("Percentage of singleton live births at any gestation that were ",
input$tob))
)
# add asterisk for planned and unplanned caesarean options for Borders footnote
title_text <- if_else(grepl("planned", title_text), HTML(paste0(title_text, "*")), HTML(title_text))
})