I have run multiple models using two data sets: 'Africa' and 'Asia'. I would like to plot all model outputs in one dot and whisker plot, where Africa and Asia data are colour coded. An example of my data below and plot:
term <- c("male", "male", "female", "female")
estimate <- c(1.5, 2.1, 1.1, 1.3)
conf.low <- c(0.2, 1.1, 0.9, 0.3)
conf.high <- c(1.9, 2.2, 1.6, 1.6)
data <- c("Africa", "Asia", "Africa", "Asia")
df <- data.frame(term, estimate, lower, upper, model)
ggplot(df, aes(term, estimate, color=data)) +
theme_bw() +
geom_errorbar(aes(ymin=conf.low, ymax=conf.high),
width=0, size=1.3, position = position_dodge(width = 0.5)) +
labs(x ="", y = "Estimate")+
geom_point(size=4, position = position_dodge(width = 0.5)) +
coord_flip()
My question is: how do I get the red plot representing Africa to swap positions with the blue/Asia plot?