r - Manually set y axis tick labels in a facet wrap forest plot -


i'm producing facet wrapped forest plot , i'd manually set y-axis labels.

here's example data:

set.seed(1) df <- data.frame(x=rnorm(10),y=c(1:5,1:3,1:2),                  group=c(rep("a",5),rep("b",3),rep("c",2)),                  name=c(paste("a",1:5,sep=""),paste("b",1:3,sep=""),paste("c",1:2,sep=""))) df$xmin <- df$x-runif(10,0.5,0.7) df$xmax <- df$x+runif(10,0.5,0.7) 

and here's code i'm trying:

library(ggplot2) p <- ggplot(df,aes(y = y, x = x))+   geom_point()+   scale_y_discrete(limits = df$name, expand = c(.1,0))+   facet_wrap(~group,ncol=3,scales="free")+   geom_segment(aes(x = xmin, xend = xmax, y = y, yend = y))+   geom_vline(lty=2, aes(xintercept=0), colour = 'red') 

which produces figure:

enter image description here

as can see y-axis tick labels of middle , right facets not consistent df$name.

ggplot(df,aes(y = name, x = x)) +  geom_point() +  facet_wrap(~group,ncol=3,scales="free") +  geom_segment(aes(x = xmin, xend = xmax, y = name, yend = name)) +  geom_vline(lty=2, aes(xintercept=0), colour = 'red')