I have data here with class attendance. I have done facet wrap for 3 levels. I now want to put labels on the bars in the percentage format. How can I do this?
library(tidyverse)
nithin<-tibble::tribble(
~age, ~class_attendance,
6L, "Yes",
6L, "No",
6L, "Yes",
7L, "Yes",
7L, "Yes",
7L, "No",
8L, "No",
8L, "No",
8L, "Yes",
6L, "Yes",
6L, "No",
8L, "No",
7L, "No",
6L, "Yes",
7L, "No",
8L, "Yes",
6L, "Yes",
8L, "No"
)
nithin %>%
mutate(level=if_else(age==6,"Level 1-Age 6",if_else(age==7,"Level 2-Age 7","Level 3- Age 8"))) %>%
drop_na(class_attendance) %>%
ggplot(aes(class_attendance))+
geom_bar(width=0.5,mapping=aes(fill=class_attendance))+
facet_wrap(~level)+
theme_minimal()
Created on 2022-03-18 by the reprex package (v2.0.1)