I'm currently working on creating a funnel plot in R for a set of mortality rates. I've used the following code to create my funnel plot, and got the following plot:
fp1<-ggplot(data=agg.hd2,
aes(x=total, group=OverallDR))
fp1<-fp1 + geom_smooth(aes(y=lcl95),
se = FALSE,
linetype="solid",
color = "red",
size=0.5)
fp1<-fp1 + geom_smooth(aes(y=ucl95),
se = FALSE,
linetype="solid",
color = "red",
size=0.5)
fp1<-fp1 + geom_smooth(aes(y=lcl99.8),
se = FALSE,
linetype="solid",
color="blue",
size=0.5)
fp1<-fp1 + geom_smooth(aes(y=ucl99.8),
se = FALSE,
linetype="solid",
color="blue",
size=0.5)
fp1<-fp1+geom_smooth(aes(y=OverallDR),
se=FALSE,
color="black",
size=0.5)
fp1<-fp1 + geom_point(aes(y=DRbyhosp),
color ="black")
fp1<-fp1 + theme_classic()
fp1<-fp1 + scale_x_continuous(breaks=seq(0,6000, by=500))
fp1<-fp1 + scale_y_continuous(labels = scales::percent)
fp1<-fp1 + labs(title="Funnel Plot showing Death Rate for Each Hospital")
fp1<-fp1 + labs(x="Operations Performed")
fp1<-fp1 + labs(y="Death Rate")
fp1
I wish to display labels for all of the points which are above or below the blue (99.8%) line. I've tried the subsetting solutions suggested on other threads, but haven't been able to make them work. Does anyone have any suggestions of how I can achieve this?