Including Plots

You can also embed plots, for example:

# Import from live Google Sheet
url <- "[https://docs.google.com/spreadsheets/d/10EdmTHgJIxsBg1Qj5RIAS8vB3vHYl4J1cLd-y9Lj54o/edit?usp=sharing](https://docs.google.com/spreadsheets/d/10EdmTHgJIxsBg1Qj5RIAS8vB3vHYl4J1cLd-y9Lj54o/edit?usp=sharing)"

df <- gsheet2tbl(url) %>% 
  clean_names() %>%
  # Cleaning data: Remove empty rows and trim text
  filter(!is.na(patient_id)) %>%
  mutate(across(where(is.character), str_trim))
descriptive_tab <- df %>%
  select(age, gender, icu_reason, icu_experience, sterilization) %>%
  tbl_summary(
    label = list(
      age ~ "Age Group",
      gender ~ "Gender",
      icu_reason ~ "Reason for ICU Admission",
      icu_experience ~ "Physician Experience Level",
      sterilization ~ "Equipment Sterilization Method"
    ),
    missing = "no"
  ) %>%
  add_ci() %>% # Add 95% Confidence Intervals
  bold_labels() %>%
  modify_caption("**Table 1: Descriptive Statistics of the Study Population**")

descriptive_tab
Table 1: Descriptive Statistics of the Study Population
Characteristic N = 4061 95% CI
Age Group

    1. Newborn (0–30 days) 15 (3.7%) 2.2%, 6.2%
    2. Infant one month to one year 29 (7.1%) 4.9%, 10%
    3. Child (one to twelve years old) 1 (0.2%) 0.01%, 1.6%
    4. Adult between 13 and 50 years of age 2 (0.5%) 0.09%, 2.0%
    5. People over 50 years old 70 (17%) 14%, 21%
    6. Please indicate the age. 12 (3.0%) 1.6%, 5.2%
    Infant, one month to one year 89 (22%) 18%, 26%
    Newborn (0–30 days) 29 (7.1%) 4.9%, 10%
    People over 50 years old 148 (36%) 32%, 41%
    Please indicate the age. 11 (2.7%) 1.4%, 4.9%
Gender

    Female 188 (46%) 41%, 51%
    Male 218 (54%) 49%, 59%
Reason for ICU Admission

    Cardiac arrest and after surgery recovery 104 (26%) 21%, 30%
    Failure of respiratory systems 86 (21%) 17%, 26%
    neurological disability 52 (13%) 9.8%, 17%
    neurological disability; Other (please indicate) 1 (0.2%) 0.01%, 1.6%
    Sepsis 45 (11%) 8.3%, 15%
    Trauma—such as multiple injuries or cerebral damage 118 (29%) 25%, 34%
Physician Experience Level

    five to ten years 143 (35%) 31%, 40%
    less than five years 125 (31%) 26%, 36%
    ten years or more 138 (34%) 29%, 39%
Equipment Sterilization Method

    Absence of a methodical sterilizing plan 169 (42%) 37%, 47%
    Absence of a methodical sterilizing plan; 1 (0.2%) 0.01%, 1.6%
    Periodically cleaned 109 (27%) 23%, 31%
    Strict compliance—autoclave after each usage 127 (31%) 27%, 36%
Abbreviation: CI = Confidence Interval
1 n (%)
ggplot(df, aes(x = age, fill = age)) +
  geom_bar(show.legend = FALSE) +
  geom_text(stat='count', aes(label=..count..), vjust=-0.5) +
  labs(title = "Figure 1: Distribution of Patients by Age Group", 
       x = "Age Category", y = "Number of Patients") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

# Visualizing the frequency of different intubation complications
df %>%
  count(intubation_complication) %>%
  ggplot(aes(x = reorder(intubation_complication, n), y = n)) +
  geom_col(fill = "steelblue") +
  coord_flip() +
  labs(title = "Figure 2: Types of Intubation Complications Observed", 
       x = "Complication Type", y = "Frequency") +
  theme_minimal()

##

df %>%
  select(age, intubation_complication, cardiac_arrest) %>%
  tbl_summary(
    by = age,
    label = list(intubation_complication ~ "Complication Type")
  ) %>%
  add_p(test = all_categorical() ~ "fisher.test", 
        test.args = all_categorical() ~ list(simulate.p.value = TRUE)) %>%
  bold_labels() %>%
  modify_caption("**Table 2: Complications Categorized by Patient Age**")
Table 2: Complications Categorized by Patient Age
Characteristic 1. Newborn (0–30 days)
N = 15
1
2. Infant one month to one year
N = 29
1
3. Child (one to twelve years old)
N = 1
1
4. Adult between 13 and 50 years of age
N = 2
1
5. People over 50 years old
N = 70
1
6. Please indicate the age.
N = 12
1
Infant, one month to one year
N = 89
1
Newborn (0–30 days)
N = 29
1
People over 50 years old
N = 148
1
Please indicate the age.
N = 11
1
p-value2
Complication Type









0.001
    Airway trauma (e.g. vocal cord damage lacerations) 0 (0%) 0 (0%) 0 (0%) 0 (0%) 7 (10%) 0 (0%) 0 (0%) 0 (0%) 0 (0%) 0 (0%)
    Airway trauma (e.g., vocal cord damage, lacerations) 7 (47%) 5 (17%) 0 (0%) 0 (0%) 17 (24%) 6 (50%) 27 (30%) 9 (31%) 54 (36%) 3 (27%)
    Desaturation during the process; o Cardiac arrest during intubation; other (please describe) 0 (0%) 3 (10%) 0 (0%) 0 (0%) 5 (7.1%) 4 (33%) 9 (10%) 7 (24%) 22 (15%) 1 (9.1%)
    Esophageal intubation 6 (40%) 5 (17%) 0 (0%) 0 (0%) 9 (13%) 0 (0%) 17 (19%) 5 (17%) 16 (11%) 2 (18%)
    Hemodynamic instability (e.g., hypotension, arrhythmia) 0 (0%) 10 (34%) 0 (0%) 0 (0%) 13 (19%) 1 (8.3%) 18 (20%) 2 (6.9%) 24 (16%) 3 (27%)
    Hypoxia 2 (13%) 6 (21%) 1 (100%) 2 (100%) 19 (27%) 1 (8.3%) 18 (20%) 6 (21%) 32 (22%) 2 (18%)
cardiac_arrest









<0.001
    No cardiac arrest did not happen 0 (0%) 2 (6.9%) 0 (0%) 2 (100%) 13 (19%) 0 (0%) 0 (0%) 0 (0%) 0 (0%) 0 (0%)
    No, cardiac arrest did not happen 7 (47%) 17 (59%) 0 (0%) 0 (0%) 40 (57%) 8 (67%) 71 (80%) 22 (76%) 122 (82%) 8 (73%)
    Yes 8 (53%) 10 (34%) 1 (100%) 0 (0%) 17 (24%) 4 (33%) 18 (20%) 7 (24%) 26 (18%) 3 (27%)
1 n (%)
2 Fisher’s Exact Test for Count Data with simulated p-value (based on 2000 replicates)
df %>%
  select(checklist_compliance, intubation_complication, intubation_success) %>%
  tbl_summary(
    by = checklist_compliance,
    label = list(intubation_complication ~ "Complication Type",
                 intubation_success ~ "First-Pass Success Rate")
  ) %>%
  add_p(test = all_categorical() ~ "chisq.test") %>%
  add_overall() %>%
  modify_caption("**Table 3: Safety Outcomes by Protocol Compliance**")
Table 3: Safety Outcomes by Protocol Compliance
Characteristic Overall
N = 405
1
Absence of a systematic procedure
N = 29
1
Adherence to procedures
N = 35
1
Consistently adhered to
N = 113
1
o. Consistently adhered to
N = 6
1
o. Occasionally adhered to
N = 2
1
Occasionally adhered to
N = 143
1
Seldom or never adhered to
N = 77
1
p-value2
Complication Type







<0.001
    Airway trauma (e.g. vocal cord damage lacerations) 7 (1.7%) 0 (0%) 0 (0%) 1 (0.9%) 2 (33%) 1 (50%) 2 (1.4%) 1 (1.3%)
    Airway trauma (e.g., vocal cord damage, lacerations) 128 (32%) 13 (45%) 7 (20%) 31 (27%) 0 (0%) 0 (0%) 50 (35%) 27 (35%)
    Desaturation during the process; o Cardiac arrest during intubation; other (please describe) 51 (13%) 7 (24%) 6 (17%) 15 (13%) 0 (0%) 0 (0%) 13 (9.1%) 10 (13%)
    Esophageal intubation 60 (15%) 4 (14%) 4 (11%) 16 (14%) 0 (0%) 0 (0%) 19 (13%) 17 (22%)
    Hemodynamic instability (e.g., hypotension, arrhythmia) 71 (18%) 2 (6.9%) 11 (31%) 15 (13%) 0 (0%) 0 (0%) 30 (21%) 13 (17%)
    Hypoxia 88 (22%) 3 (10%) 7 (20%) 35 (31%) 4 (67%) 1 (50%) 29 (20%) 9 (12%)
First-Pass Success Rate







0.5
    85% or more first-pass intubation success rate 7 (88%) 0 (NA%) 0 (NA%) 0 (NA%) 6 (100%) 1 (50%) 0 (NA%) 0 (NA%)
    Less than 50% 1 (13%) 0 (NA%) 0 (NA%) 0 (NA%) 0 (0%) 1 (50%) 0 (NA%) 0 (NA%)
    Unknown 397 29 35 113 0 0 143 77
1 n (%)
2 Pearson’s Chi-squared test
df %>%
  select(icu_experience, intubation_success, cardiac_arrest) %>%
  tbl_summary(
    by = icu_experience,
    label = list(intubation_success ~ "Success Status",
                 cardiac_arrest ~ "Cardiac Arrest during Procedure")
  ) %>%
  add_p(test = all_categorical() ~ "fisher.test", 
        test.args = all_categorical() ~ list(simulate.p.value = TRUE)) %>%
  modify_caption("**Table 4: Relationship between Experience and Procedural Success**")
Table 4: Relationship between Experience and Procedural Success
Characteristic five to ten years
N = 143
1
less than five years
N = 125
1
ten years or more
N = 138
1
p-value2
Success Status


0.6
    85% or more first-pass intubation success rate 2 (100%) 2 (67%) 4 (100%)
    Less than 50% 0 (0%) 1 (33%) 0 (0%)
    Unknown 141 122 134
Cardiac Arrest during Procedure


0.8
    No cardiac arrest did not happen 4 (2.8%) 6 (4.8%) 7 (5.1%)
    No, cardiac arrest did not happen 109 (76%) 88 (70%) 98 (71%)
    Yes 30 (21%) 31 (25%) 33 (24%)
1 n (%)
2 Fisher’s Exact Test for Count Data with simulated p-value (based on 2000 replicates)