I'm trying to make a publication ready plot with odds ratios as well as upper und lower ci's. Now I did get nice graphs with ggplot but I want to add significance stars above the geom_point-layer, that correspond to the three levels (.005,.001,.001). I made up an example dataframe which I'm getting my values from. It also includes the p-values:
or<-as.numeric(round(rnorm(5,0,1),2))
n<-c(100,100,100,100,100)
p<-c(.06,.05,.01,.0012,.000034)
df<-as.data.frame(cbind(or,n,p))
df$names<-as.factor(c(1:5))
df$lwr.ci<-as.numeric(or-2)
df$upr.ci<-as.numeric(or+2)
The ggplot-code is as follows:
p <- ggplot(df, aes(or, fct_rev(names)))+
theme_bw(base_family = "Times New Roman")
p+geom_errorbarh(aes(xmax =upr.ci, xmin = lwr.ci), size = 1, height = 0, color = 'gray') +
geom_point(size = 2, color = 'black') +
theme(panel.grid = element_blank()) +
scale_x_continuous(breaks = c(0:13),limits = c(-4,5))+
ylab('CD') +
xlab('Odds Ratios')+
ggtitle('R')+
geom_text(parse=T,aes(label=paste(round(or,2),sep =" ","(","italic(n)==",n,")")),x= -3.5, size = 3,color='black',family="Times New Roman")
If anybody has a suggestions on how to add the corresponding significance stars to the geom_points, I would be very grateful.