Plot age intervals on y axis with ggplot

Viewed 32

I'm trying to show the amount of young and old legislators participating in parliamentary sessions. The birthyear variable indicates the year, I've written the code so that R will only consider the first 4 characters of the observation (aka the year).

I basically want to show how many people participated that were born in these intervals: 1930-1950, 1951-1970, 1971-1990, 1991-2020.

I'm attaching my code, which does work but gives me a very weird plot. Age should be on the y axis and the sessions (14 in total) on the x axis.

Thanks in advance for any hints!

mergedf$birthyear <- substr(mergedf$birth, 1, 4) 

mergedf %>%
ggplot(aes(x = session, y = birthyear)) + geom_bar(stat = "identity")+
  theme_minimal()+
  theme(legend.position ="bottom")+
  labs(title = "Party groups present at sessions", x= "Session", y = "Present party groups")
0 Answers
Related