How to include geom_label for a column ggplot?

Solution 1:

You could achieve your desired result like so:

  1. As for the bars set position="fill" in geom_label too.
  2. To only add the val if count=TRUE use an ifelse which assigns an NA to FALSE.
  3. To silence the warning about removed missing use na.rm=TRUE.
library(ggplot2)

ggplot(test, aes(x = pct, y = `Marketing Variables`, fill = count)) +
  geom_col(position = "fill") +
  geom_label(aes(label = ifelse(count, val, NA_character_)), position = "fill", na.rm = TRUE, show.legend = FALSE) +
  theme_minimal() +
  facet_wrap(~LICENCE_STATUS)