Lets say I have
As you can see, there are 0 Complete Response in WHO-1
, but there are cases in the other categories. So, it looks graphically off that there are three geom_col
-bars in the WHO-1
-category and four geom_col
-bars in the other two.
How can I add a fourth bar to WHO-1
indicating the space corresponding to Complete Response?
Something like
Script
pp %>%
as_tibble() %>%
mutate(nyWHO = as.factor(WHO),
best.resp = as.factor(case_when(best_rad == "CR" ~ 4,
best_rad == "PR" ~ 3,
best_rad == "SD" ~ 2,
best_rad == "PD" ~ 1))) %>%
count(nyWHO, best.resp) %>%
ggplot(aes(nyWHO, n, color = best.resp, fill= best.resp)) +
scale_fill_manual(values = alpha(c("#6DBCC3", "#8B3A62", "grey40", "#E1B930"), 0.4),
name="",
labels = c("Progressive disease", "Stable disease", "Partial response", "Complete response")) +
scale_colour_manual(values = cols,
name="",
labels = c("Progressive disease", "Stable disease", "Partial response", "Complete response")) +
geom_col(width=1, position = position_dodge2(width = 1, preserve = "single")) +
geom_text(aes(label = n), position = position_dodge2(width = 1, preserve = "single"),
vjust=-0.5, size = 10, show.legend = F) +
scale_x_discrete(name = "", labels = c("WHO-1", "WHO-2", "WHO-3")) +
scale_y_continuous(name="", breaks = seq(0, 80, by = 20)) +
coord_cartesian(ylim=c(0, 80)) +
theme(axis.title.x = element_text(size = 22),
axis.title.y = element_text(size = 22),
axis.text.x = ggtext::element_markdown(color = "grey20", size = 20),
axis.text.y = element_text(color = "grey20", size = 18),
panel.grid.major = element_line(colour = "gray90", size = 1.2),
panel.grid.minor = element_line(colour = "gray90", size = 0.6),
legend.text = element_text(size = 22),
legend.position = "top")
Data
pp <- structure(list(WHO = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 1L, 3L, 1L, 3L, 3L, 2L, 3L, 1L, 1L, 2L, 1L, 1L, 3L, 2L, 1L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 2L, 3L, 2L, 3L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 3L, 2L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 3L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 3L, 3L, 3L, 3L, 3L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 3L, 2L, 2L, 2L, 3L, 2L, 3L, 3L), .Label = c("1", "2", "3"), class = "factor"), best_rad = c("SD", "SD", "CR", "CR", "SD", "SD", "SD", "SD", "PR", "PR", "PR", "PR", "CR", "CR", "PR", "PR", "PR", "SD", "PD", "PR", "PD", "SD", "SD", "PD", "PD", "PD", "PD", "SD", "PD", "PR", "PD", "PD", "PD", "PD", "SD", "PD", "SD", "SD", "PD", "PD", "PD", "PD", "PD", "PD", "PD", "PD", "PD", "PD", "PD", "PD", "SD", "PD", "PD", "PD", "PD", "SD", "PD", "PD", "SD", "SD", "SD", "PD", "SD", "PD", "SD", "SD", "PD", "PD", "SD", "PD", "PD", "PD", "SD", "SD", "SD", "SD", "PD", "SD", "PD", "SD", "PD", "SD", "PD", "SD", "PD", "SD", "SD", "PD", "SD", "SD", "SD", "PD", "SD", "SD", "SD", "PD", "PD", "PD", "SD", "SD", "SD", "CR", "SD", "SD", "SD", "PD", "PD", "PD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "SD", "PD", "PD", "SD", "SD", "PD", "PD", "PD", "SD", "PD")), row.names = c(NA, -133L), class = "data.frame")