I'm drawing some figures that have overlayed points across two groups, which are dodged to make the groups clear. One of the groups' points are shown across two experimental conditions (shown on the x axis), and I want to join up these two sets of points using lines. I also want to make the means and the data points distinct by filling in the means and leaving the individual data points empty. Basically, I can't get my 'dodged' points to join up neatly with the lines, even when I dodge the lines as well.
As an example using sample data:
group <- c("high", "high", "high", "low", "low", "low", "high", "high", "high", "low", "low", "low")
condition <- c("c1", "c1", "c1", "c1", "c1", "c1", "c2", "c2", "c2", "c2", "c2", "c2")
value <- c(.91, .63, .5, NA, NA, NA, .93, .76, .43, .5, .6, .8)
subj <- c("s1", "s2", "s3", "s4", "s5", "s6")
sample.data <- data.frame(group, condition, value, subj)
ggplot(sample.data, aes(x=condition, y=value)) +
geom_point(aes(colour=group, shape = group), size = 2, position = position_dodge(.1)) +
scale_shape_manual(values=c(2,1)) +
geom_line(aes(group=subj), colour='lightgrey') +
stat_summary(fun.y=mean, geom = "point", aes(shape=group, fill = group),
size=5, position = position_dodge(.1)) +
stat_summary(fun.y = mean, aes(group=group, colour=group), geom='line',
size=.8, position = position_dodge(.1))
As you can see in the example figure, the lines are not joining up the points, even though I have 'dodged' the line as well. Is there a neat way to get ggplot to do this?
Many thanks!