Error bar in bar plot

Hi,
I'm new to R and I'm trying to plot a grouped bar plot with se bars, but without any success.

responses_plot <- ggplot(hu_sum2, aes(y=N,x=Answer_Type,fill=Group)) + labs(y='Number of Answers') + geom_bar(stat ="identity", position = "dodge") + facet_wrap("Condition") + theme_bw() + theme(axis.text.x = element_text(angle = 70, hjust = 1)) + xlab("Type of Answer")+ scale_fill_brewer(palette = "Pastel1") responses_plot

I tried adding to my plot this:

+ stat_summary(geom = "bar", fun.y = mean, position = "dodge") + stat_summary(geom = "errorbar", fun.data = mean_se, position = "dodge")

This is my subset on which I am plotting the data:


Thank you to anyone who could help!

Hi, welcome!

A screenshot of your data is not very useful, could you please turn this into a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

Also: Tell us more what is working and what isn't. I'd guess the first part is working? Then you want to add the second part and this is not working?
This: + stat_summary(geom = "bar", fun.y = mean, position = "dodge") isn't needed as you already show the bars. Additionally this (and the errorbar) probably will not work as you already import summarised data (as it can be seen from the screenshot)
Do you have multiple entries per condition in your dataset? Let's say for Control/Correct Humorous? Then you could use the stat_summary functions that calculate the values on the fly.
Or do you have the SD/SE already calculated in the column after the N? Then you have to use this instead!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.