I am trying to create a grouped bar chart with 4 bars in total (wish of men with no support, wish of women with no support, wish of men who received support, wish of women who received support), plus error bars. The variable "wish" is measured on a scale from 1-5 so I am trying to set the limits accordingly, but this leads to only the error bars but not "main" bars being displayed in the graph, and following error message occurs:
Warning message:
Removed 4 rows containing missing values (geom_bar()
).
ggplot(wish_c, aes(x=factor(esnonrom_t,
levels = c("0", "1"),
labels = c("Received no support (n = 89)", "Received support (n=795)")),
y=wish_for_partner_t1,
fill=factor(sex_gen,
levels = c("0", "1"),
labels=c("Men (n=427)", "Women(n=457)")))) +
geom_bar(position=position_dodge(), stat="identity") +
geom_errorbar(aes(ymin=wish_t1-se, ymax=wish_t1+se),
width=.2, # Width of the error bars
position=position_dodge(.9)) +
scale_y_continuous("Wish (1-5)", limits=c(1,5), breaks=seq(1,5, by =1)) +
theme_classic() +
scale_fill_brewer(palette = "Greys") +
labs(x = "Emotional support received
beyond the romantic relationship",
fill = "Gender",
title = "Wish by gender and emotional support")