Data
DATA = data.frame(school = c("A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B"),
gender=c("M","M","M","M","F","F","F","F","M","M","M","M","F","F","F","F"),
grade = c(10,11,12,13,10,11,12,13,10,11,12,13,10,11,12,13),
score=c(97,85,95,98,84,90,55,84,52,65,83,75,95,74,76,71))
My try
ggplot(DATA, aes(x=grade, y=score, fill = gender)) +
geom_bar(stat= "identity", alpha = 0.3) +
geom_text(size = 3, position = position_stack(vjust = 0.5))
ggplot(DATA, aes(x=grade, y=score, fill = school)) +
geom_bar(stat='identity', position='dodge')
I can do a plot that is stack (see plot number 1) and a plot side by side (see plot number 2) but how do I combine so gender is stacked and compared side by side by school?