Home > other >  geom_col in R making bars next to each other
geom_col in R making bars next to each other

Time:04-07

With the following code

A2c%>%
  group_by (maritalStatus, Geschlecht)%>%
  summarise (nbr_total=n(), nbr_adipos=sum(Adipös))%>%
  mutate( adipos_prozent = 100 * nbr_adipos / nbr_total )%>%
  filter (maritalStatus != "Refused")%>%
  ggplot 
  geom_col(aes(x=maritalStatus, y= adipos_prozent, color = Geschlecht, fill=Geschlecht)) 
  theme(axis.text.x = element_text(angle = 90)) 
  labs(y = "% Adipöser", x = "Marital Status")

I get this plot: enter image description here

As you can see the bars are now nicely displayed. (Don't look at the numbers, they are fake)

  • Related