Skip to contents

This vignette demonstrates plot_hai_totals(), a quick wrapper around ggplot2 for bar charts of HAI totals by infection type, age group, or sex.

library(haiInsight)
data("hai_data_clean")
head(hai_data_clean)
## # A tibble: 6 × 4
##   Age_Group Sex   Count Infection_Type
##   <chr>     <chr> <int> <chr>         
## 1 [0;0]     F         0 HAP           
## 2 [0;0]     M         0 HAP           
## 3 [1;4]     F         0 HAP           
## 4 [1;4]     M         0 HAP           
## 5 [5;9]     F         0 HAP           
## 6 [5;9]     M         0 HAP

By infection type

plot_hai_totals(hai_data_clean, by = "Infection_Type")

Bar chart showing total infections by infection type

By age group

plot_hai_totals(hai_data_clean, by = "Age_Group")

Bar chart showing total infections by age group

By sex

plot_hai_totals(hai_data_clean, by = "Sex")

Bar chart showing total infections by sex

Learn More

For a deeper dive into summarising infection counts before plotting,
see the companion vignette: summarising-hai.


Next vignette: Learn how to summarise totals before plotting in summarising-hai.