I don't why my graph looks this way or how to fix it. I've adapted the code from a two-groups graph to 3 groups. How do I remove the NA from the graph and center the error bars and dots?
a = ggplot(tmp.df, aes(Goal, Score, fill=group)) +
geom_boxplot(stat = "boxplot",position = "dodge2",outlier.shape = NA, coef = 0, na.rm = TRUE) +
geom_errorbar(data = x, aes(y=fit, ymin=lower, ymax=upper), width=0.3, position = position_dodge(0.4)) +
geom_point(data = x, aes(y=fit), position = position_dodge(0.4)) +
scale_fill_manual(name = "group", labels = c("General", "Religious", "Minorities"),
values = c("firebrick4", "deepskyblue4","hotpink2")) + coord_cartesian(ylim = c(0, 4)) +
ylab("Goal's Importance") +
theme_bw(base_size=13) +
theme(axis.text.x = element_text(angle = 345),
panel.grid.major.x = element_blank())
Also, why do I keep getting this error message?
> ggsave(a, filename = "4.png", width = 180, height = 160, units = "mm", bg = "transparent") +
#scale_fill_discrete( labels = c("General", "Religious", "Minorities")) +
ggtitle("Goals' Importance by Group")
Error in ggsave(a, filename = "4.png", width = 180, height = 160, units = "mm", : non-numeric argument to binary operator