I have a factor of time that has two levels, admission and discharge. I'm using facet_grid
to create four panels in which my continuous Y will be looked at by time. I want to be able to add a mean line to each of the two time levels in each panel. My problem is that the mean line spans the entire width of the panel and I'd like to shorten it to just remain within the area of the dots.
Here is the code:
plot <- ggplot(data.in, aes(x=Time, y=Y)) + geom_point()
plot <- plot + facet_grid(.~FacetGroup)
data_hline <- aggregate(data.in$Y~data.in$Time + data.in$FacetGroup, FUN=mean)
plot + geom_hline(data=data_hline, aes(yintercept=Y))