Increase space between color groups on coefficient plot

Viewed 52

I'm making a plot of regression coefficients using ggplot in R. Here's an example data frame of what my results look like:

test_plot <- data.frame(outcome=rep(c('Variable 1', 'Variable 2'),6),
wave=c(rep('midline',6),rep('endline',6)),
model=rep(c('Base Model','Base Model','Covariates','Covariates','Matched','Matched'),2),
estimate=c(-.187,-.065,-.177,-.062,-.173,-.062,-.064,-.045,-.057,-.038,-.082,-.044),
ci.low=c(-.281,-.159,-.271,-.155,-.269,-.158,-.155,-.135,-.146,-.129,-.181,-.141),
ci.high=c(-.092,.028,-.083,.031,-.076,.033,.025,.044,.032,.052,.017,.053))

I then create a plot of the results, disaggregated by the wave of the survey (represented as different colors) and the type of model (represented by different shapes). I use position_dodge() to increase the space between the bars and points for the different models within each variable.

library(ggplot2)
ggplot(test_plot,aes(x=estimate, y=outcome, color = wave, shape = model, fill = wave)) + 
        geom_point(size=3,position = position_dodge(width=.6)) + 
        geom_errorbarh(aes(xmin=ci.low, xmax=ci.high), position=position_dodge(width=.6), height=0) + 
        geom_vline(xintercept=0, linetype="dotted")

My question is: how do you increase the space between the groups of points/errorbars that are separated by the "color" variable (in this case, "wave")? In other words, I want to increase the space between the blue "midline" bars and the red "endline" bars for each outcome.

current code output

0 Answers
Related