# Paired plots for PLWH comparing years
for (organ_loop in organ_list) {
for (distance_loop in distance_list){
#Create distance label
distance_label <- dplyr::case_when(
stringr::str_detect(distance_loop, "mile$") ~
paste0(stringr::str_remove(distance_loop, "mile"), " miles"),
stringr::str_detect(distance_loop, "min$") ~
paste0(stringr::str_remove(distance_loop, "min"), " mins")
)
#Create paired plot for active, no HIV
paired_plot<-make_paired_plot(organ=organ_loop,
distance=distance_loop,
outcome="active",
buffer_list=Transplant_centers_active_buffer,
year1="2017",
year2="2022",
plottitle=glue::glue("Active {organ_loop} transplant center, {distance_label}")
)
ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} active.svg"),
paired_plot,
width = 12, height = 6, units = "in",
bg = "white")
ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} active.png"),
paired_plot,
width = 12, height = 6, units = "in",
dpi = 150,
device = ragg::agg_png,
bg = "white")
#Create paired plot for active, comparing HIV to non-HIV
paired_plot<-make_paired_plot(organ=organ_loop,
distance=distance_loop,
outcome="active",
buffer_list=Transplant_centers_active_buffer,
year1="2017",
year2="2022",
plottitle=glue::glue("Active {organ_loop} transplant center, {distance_label}"),
include_nonHIV = TRUE
)
ggsave(glue("figures/{organ_loop}/Active{organ_loop}CenterCombinedPlot{distance_loop}.svg"),
paired_plot,
width = 12, height = 6, units = "in",
bg = "white")
ggsave(glue("figures/{organ_loop}/Active{organ_loop}CenterCombinedPlot{distance_loop}.png"),
paired_plot,
width = 12, height = 6, units = "in",
dpi = 150,
device = ragg::agg_png,
bg = "white")
#Create paired plot for HIV
paired_plot<-make_paired_plot(organ=organ_loop,
distance=distance_loop,
outcome="HIV",
buffer_list=Transplant_centers_HIV_buffer,
year1="2017",
year2="2022",
plottitle=glue::glue("Active HIV R+ {organ_loop} transplant center, {distance_label}"))
ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} HIV.svg"),
paired_plot,
width = 12, height = 6, units = "in",
bg = "white")
ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} HIV.png"),
paired_plot,
width = 12, height = 6, units = "in",
dpi = 150,
device = ragg::agg_png,
bg = "white")
#Create paired plot
paired_plot<-make_paired_plot(organ=organ_loop,
distance=distance_loop,
outcome="HOPE",
buffer_list=Transplant_centers_HOPE_buffer,
year1="2017",
year2="2022",
plottitle=glue::glue("Active HOPE D+/R+ {organ_loop} transplant center, {distance_label}"))
ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} HOPE.svg"),
paired_plot,
width = 12, height = 6, units = "in",
bg = "white")
ggsave(glue("figures/{organ_loop}/Combined {organ_loop} plot 2026-2-14 {distance_loop} HOPE.png"),
paired_plot,
width = 12, height = 6, units = "in",
dpi = 150,
device = ragg::agg_png,
bg = "white")
}
}