Sort of a R rookie here. I'm trying to create a bar chart with three separate bars to represent the sum of correct answers for the control, treatment and both combined but the dodge argument doesn't seem to be working. I'll attach my R code here.
ggplot(correct.data3, aes(x = Question)) +
geom_bar(aes(y = Both, fill = "Both"), position = 'dodge',
stat = "identity") +
geom_bar(aes(y = Control, fill = "Control"), position = 'dodge',
stat = "identity") +
geom_bar(aes(y = Treatment, fill = "Treatment"), position = 'dodge',
stat = "identity") +
labs(title = "Correct Responses",
y = "Number of Correct Responses",
fill = "Treatment Group") +
theme_bw()
I wanted to use ggplot2
to create a bar chart with the x-axis reading Q1, Q2, Q3, Q4 and for each question to have three bars representing the correct responses for both, control and treatment groups. I tried using the dodge argument but the bars seemingly overlap. How can I solve this?