I have four variables as columns in my data set:
- whether the person had free school meals when they were younger
- whether the person's parents attended university
- whether the person studied A-level drama at school
- whether their school offered A-level drama
Each value in the column is either "yes", "no" or "not applicable".
I want to put four sets of bar charts on one single plot (which I can then save as a .png), with each of the bar charts having a yes bar and a no bar. I have used the below to create a frequency table for each of the variables. Here I've used the example of whether the person received free school meals (FSM) when they were younger:
FSM_df <- champions %>% count(FSM, sort = TRUE) %>% mutate(pct = prop.table(n))
percentage = label_percent()(FSM_df$pct)
FSM_df$percentage = percentage
I can use the code below to create a single bar chart, but I'm not sure how to do this for multiple plots:
ggplot(FSM_df, aes(x = FSM, y = n, fill = "#fe8080")) + geom_bar(stat = "identity", show.legend = FALSE) + coord_flip() + labs(x = "FSM", y = "Number of Champions") + geom_text(aes(label = percentage), color = "#662483")