df_graph <-
df_volume %>%
select(starts_with("hypo")) %>%
pivot_longer(
cols = hypo_tachycardia:hypo_bp,
values_drop_na = T) %>%
group_by(name, value) %>%
count() %>%
pivot_wider(id_cols = name, names_from = value, values_from = n) %>%
mutate(
N = 30,
n = case_when(is.na(Yes) ~ 0, TRUE ~ Yes)) %>%
select(-c(Yes, No)) %>%
mutate(xx = epiDisplay::ci.binomial(n, N)) %>%
unnest(xx) %>%
mutate(
name = factor(
name,
levels = c(
"hypo_bun_cr", "hypo_fena", "hypo_bp",
"hypo_tachycardia", "hypo_ivcci", "hypo_crt", "hypo_sg"),
labels = c(
"BUN/Cr Ratio", "Fractional Excr. Na",
"Blood Pressure", "Tachycardia",
"IVC Collapsibility Index","Capillary Refill Time",
"Specific Gravity")))
label_x <-
df_graph %>%
arrange(probability) %>%
mutate(
mm = paste0(
sprintf("%.1f", probability*100),
" (",
sprintf("%.1f", exact.lower95ci*100),
" to ",
sprintf("%.1f", exact.upper95ci*100),
")"))
df_graph %>%
ggplot(
aes(
x = name, y = probability, color = alg,
ymin = exact.lower95ci, ymax = exact.upper95ci)) +
geom_col(
fill = "steelblue",
color = "steelblue", alpha = 0.4) +
geom_errorbar(color = "steelblue", width = 0.15)+
labs(
y = "Percentage Hypovolemia(%)",
x = NULL)+
annotate(
geom = "text",
x = 1:7,
y = rep(1.05,7),
label = rev(label_x$mm),
size = 3.5,
fontface = "plain",
hjust = 0,
vjust = 0.5)+
theme_bw()+
scale_y_continuous(
br = seq(0, 1, 0.2),
labels = seq(0, 100, 20),
limits = c(0,1.5),
expand = c(0,.01))+
theme(
axis.text.x = element_text(
angle = 90, hjust = 1, vjust = 0.05,
face = "italic"))+
coord_flip()