\(STACKED~ BARS\)
library(tidyverse)
datos <- tibble(Category = c('A', 'A', 'B', 'B', 'C', 'C', 'A', 'A', 'B', 'B', 'C', 'C'),
Targeting = c('Automatic', 'Manual','Automatic', 'Manual','Automatic', 'Manual', 'Automatic', 'Manual','Automatic', 'Manual','Automatic', 'Manual'),
SpendPercentage = c(35.3, 64.7, 12.9, 87.1, 73.9, 26.1, 73.3, 26.7, 50.4, 49.6, 35, 65),
OptimizationType = c('Unoptimized', 'Unoptimized', 'Unoptimized','Unoptimized', 'Unoptimized', 'Unoptimized','Optimized', 'Optimized', 'Optimized', 'Optimized', 'Optimized', 'Optimized'))
datos %>%
ggplot(aes(x = Category, y = SpendPercentage, fill = Targeting)) +
geom_col(position = "fill", color = "black") +
scale_fill_manual(values=c('#CD6497','#93C542'), name='')+
facet_wrap(~ OptimizationType) +
geom_text(aes(label = paste0(round(SpendPercentage, 1), "%")),
position = position_fill(vjust = 0.5), size=3) +
labs(x = "Category", y = "Spend Percentage", fill = "Targeting") +
coord_flip() +
theme_minimal()+
theme(legend.position = 'bottom')