Consider this data (note that foo
is actually a factor.):
foo bar outcome ci
1 a 0.683333333 0.247447165
2 b 0.941666667 0.180356565
3
One possibility is to group
by 'bar'. Note that I also dodge
the geom_text
.
dodge <- position_dodge(.1)
ggplot(data = df, aes(x = foo, y = outcome, group = bar, label = bar)) +
geom_point(position = dodge) +
geom_errorbar(aes(ymin = outcome - ci, ymax = outcome + ci), position = dodge) +
geom_text(hjust = 2, position = dodge)