如何获得代表效果大小的钻石,包括ggplot2中的置信区间?

时间:2016-07-02 10:00:37

标签: r ggplot2

我已经写出了森林情节的代码。正如你在情节中看到的那样,我有与sqaures一起绘制的置信区间。

我希望获得吞没CI的钻石(因为这个图是摘要图),而不是这两个带有CI的正方形。

基本上,希望看到大方块的大钻石和更长的CI,反之亦然。

   #My APA-format theme


apatheme=theme_bw()+ 
  theme(panel.grid.major=element_blank(),
        panel.grid.minor=element_blank(),
        panel.border=element_blank(),
        axis.line=element_line(),
        text=element_text(family='Times'),
        legend.position='bottom', axis.text=element_text(size=14),
        axis.title=element_text(size=14,face="bold"))

credplot.gg <- function(d){
  # d is a data frame with 4 columns
  # d$x gives variable names
  # d$y gives center point
  # d$ylo gives lower limits
  # d$yhi gives upper limits
  require(ggplot2)
  p <- ggplot(d, aes(x=x, y=y, ymin=ylo, ymax=yhi))+ylim(c(-1,6))+geom_pointrange()+geom_point(aes(size=y), shape=15)+
    coord_flip() + apatheme+ geom_hline(aes(x=0,yintercept=0), lty=2)+ xlab('Studies')+ ylab('Standardized Mean Difference')+ggtitle("Comparison of treatment approaches")
  return(p)}

# load your data below 
d <- read.delim("Summary_1.txt", head=T)
Summary_1 <-credplot.gg(d) +xlim( "Simple-to-Untreated-Complex (n=4)",
                                 "Simple-to-Simple (n=11)",
                                 "Complex-to-Untreated-Simple (n=5)",
                                 "Complex-to-Complex (n=13)")



                                       x    y   ylo yhi
1   Complex-to-Complex (n=13)   0.984274064 1.061273278 0.907274851
2   Complex-to-Untreated-Simple (n=5)   2.687432561 3.53724909  1.837616031
3   Simple-to-Simple (n=11) 1.671591517 2.179163075 1.164019959
4   Simple-to-Untreated-Complex (n=4)   0.236442055 0.32407191  0.148812199

enter image description here

0 个答案:

没有答案