How to ggplot a stacked and grouped bar chart?

12 Views Asked by At

enter image description here

FINAL %>%
  ggplot(aes(x = V1, y = as.numeric(V3)/1000000, fill = V2)) + 
  geom_bar(stat= "identity", position = "dodge") + 
  labs(x=NULL, y=NULL, fill = NULL) +
  theme_classic() +
  theme(legend.position = c(0.9,0.8))
  scale_fill_grey() 

V1: are categories, V2: are years, V3/V4/V5 are numbers

As you can see I created a dodge barplot. But now I would like that for each year the variables V3 (it's already in) V4 and V5 (also numbers similar to V3) are stacked on top of each other so that one year eaquals V3+V4+V5 (but that the differentiation between V3,V4 and V5 is still visible so not just sum them together and make another dodge plot).

I hope I could explain it good enough, thanks a lot

0

There are 0 best solutions below