-
Notifications
You must be signed in to change notification settings - Fork 0
/
10_othergraphs.qmd
126 lines (107 loc) · 3.24 KB
/
10_othergraphs.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
title: "11_othergraphs"
format: html
editor: visual
---
## Facetted age/gender plot
```{r}
bar_plot_age_gender_facet <- bar_plot_age_gender +
facet_grid(. ~ Sex,
scales = "free_y") +
theme(strip.text.y = element_blank(),
strip.background = element_blank(),
axis.text.x = element_text(size = 7))
bar_plot_age_gender_facet
```
## Patch of both plot (facetted and not)
```{r}
bar_plot_age_gender_2 <- dat_aug_03 |>
ggplot(aes(x = Age,
fill = Sex)) +
geom_bar(position = "stack",
stat = "count",
alpha = 0.7) +
labs(x = "Age Group",
y = "Count") +
scale_fill_viridis_d() +
theme_minimal() +
theme(strip.text.y = element_blank(),
strip.background = element_blank(),
axis.text.x = element_text(size = 4))
bar_plot_age_gender_facet_2 <- bar_plot_age_gender_2 +
facet_grid(. ~ Sex,
scales = "free_y") +
theme(strip.text.y = element_blank(),
strip.background = element_blank(),
axis.text.x = element_text(size = 3))
combined_plot_1 <- bar_plot_age_gender_2 +
bar_plot_age_gender_facet_2
bar_plot_age_gender_2
bar_plot_age_gender_facet_2
combined_plot_1
```
## Hospitalizations by LD and comorbidities
```{r}
ggplot(stacked_bar_liverDisease,
aes(x = Liver_disease,
y=d_c_count,
fill = Comorbidities)) +
geom_bar(position = "stack",
stat = "identity") +
scale_fill_viridis(discrete = TRUE, option = "D") +
labs(title = "Hospitalizations by Liver Disease and Comorbidities",
x = "Liver Disease",
y = "Hospitalizations") +
theme_minimal() +
theme(legend.position = "right",
legend.key.height= unit(0.4, 'cm'),
legend.key.width= unit(0.2, 'cm')) +
coord_flip()
```
## Total population stacked bar plot stratified by sex
```{r}
bar_plot_total_by_gender <- dat_aug_03 |>
ggplot(aes(x = "Overall",
fill = Sex)) +
geom_bar(position = "stack",
stat = "count",
alpha = 0.7) +
labs(title = "Total Count",
x = "Patients",
y = "Count") +
scale_fill_viridis_d() +
theme_minimal()
bar_plot_total_by_gender_facet <- bar_plot_total_by_gender +
facet_grid(. ~ Sex,
scales = "free_y") +
theme(strip.text.y = element_blank(),
strip.background = element_blank(),
axis.text.x = element_text(size = 7))
```
```{r}
bar_plot_total_by_gender_2 <- dat_aug_03 |>
ggplot(aes(x = "Overall",
fill = Sex)) +
geom_bar(position = "stack",
stat = "count",
alpha = 0.7) +
labs(x = "Patients",
y = "Count") +
scale_fill_viridis_d() +
theme_minimal() +
theme(strip.text.y = element_blank(),
strip.background = element_blank(),
axis.text.x = element_text(size = 7))
bar_plot_total_by_gender_facet_2 <- bar_plot_total_by_gender_2 +
facet_grid(. ~ Sex,
scales = "free_y") +
theme(strip.text.y = element_blank(),
strip.background = element_blank(),
axis.text.x = element_text(size = 7))
combined_plot_2 <- bar_plot_total_by_gender_2 +
bar_plot_total_by_gender_facet_2 +
plot_annotation(title = "Total Count")
bar_plot_total_by_gender_2
bar_plot_total_by_gender_facet_2
combined_plot_2
```