/
graph_tb_model.R
39 lines (33 loc) · 1.11 KB
/
graph_tb_model.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
source("load_packages.R")
graph_rates <- function(df){
plot <- df %>%
gather(key = "Summary measure", value = "Incidence rate (per 100,000)",
`Annual TB incidence rate`, `TB mortality rate`) %>%
ggplot(aes(x = Year, y = `Incidence rate (per 100,000)`,
colour = `Summary measure`, group = `Summary measure`)) +
geom_line() +
theme_minimal() +
theme(legend.position = "bottom") +
expand_limits(y = 0)
return(plot)
}
graph_annual_risk <- function(df) {
plot <- df %>%
ggplot(aes(x = Year, y = `Annual risk of infection`)) +
geom_line() +
theme_minimal() +
theme(legend.position = "none") +
expand_limits(y = 0)
return(plot)
}
graph_proportions <- function(df) {
plot <- df %>%
gather(key = "Summary measures", value = "Proportions",
`Recent infection`, `Recent reinfection`, Reactivation) %>%
ggplot(aes(x = Year, y = Proportions, colour = `Summary measures`, group = `Summary measures`)) +
geom_line() +
theme_minimal() +
theme(legend.position = "bottom") +
expand_limits(y = 0)
return(plot)
}