-
Notifications
You must be signed in to change notification settings - Fork 1
/
management-report.Rmd
77 lines (56 loc) · 1.92 KB
/
management-report.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
---
title: "Dementia PDS Quarterly Management Reports"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
---
```{r setup, include=FALSE}
library(flexdashboard)
library(dplyr)
health_boards <- c("NHS Ayrshire & Arran",
"NHS Borders",
"NHS Lothian",
"NHS Tayside",
"NHS Forth Valley")
ldp <- c("success", "fail", "ongoing")
fy <- c("2016/17", "2017/18", "2018/19", "2019/20")
max_fy <- "2019/20"
data <- tibble(
health_board = sample(health_boards, 100, replace = TRUE),
ldp = sample(ldp, 100, replace = TRUE),
fy = sample(fy, 100, replace = TRUE),
referrals = sample(1:500, 100, replace = TRUE)
)
```
Notes & Methodology
=================================================
Column
-------------------------------------------------
### Section 1
```{r render subpages, include=FALSE}
# Get all unique health boards and financial years for the subpages
# TO DO: arrange alphabetically
health_boards <- unique(data$health_board)
years <- unique(data$fy)
# Create variable which stores all subpages outputs
out = NULL
# Set knitr options to allow duplicate labels (needed for the subpages)
options(knitr.duplicate.label = 'allow')
# Create temporary environment which we use for knitting subpages.RMD
subpage_env <- new.env()
for (hb in health_boards) {
for(y in years){
# Filter data for health board and financial year
subpage_data <- data %>%
filter(health_board == hb & fy == y)
# Assign filtered data, health board and fy to subpage_env
assign("subpage_data", subpage_data, subpage_env)
assign("health_board", hb, subpage_env)
assign("fy", y, subpage_env)
# Knit subpage.RMD using the subpage_env and add result to out vector
out = c(out, knitr::knit_child("markdown/subpage.Rmd", envir = subpage_env))
}
}
```
`r paste(knitr::knit_child(text = out), collapse = '')`