Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akshaycuhk/01576c57149a9a3d14514c9a3c4b4b1d to your computer and use it in GitHub Desktop.
Save akshaycuhk/01576c57149a9a3d14514c9a3c4b4b1d to your computer and use it in GitHub Desktop.
Below is a link to my code for forestplot. Basically, this is a code adapted from Abhijit's code and apatheme added from here: https://sakaluk.wordpress.com/2016/02/16/7-make-it-pretty-plots-for-meta-analysis/
#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(-10,20))+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("(C) Simple-to-Simple (n=13) ")
return(p)}
# load your data below
d <- read.delim("Meta_E_E_1.txt", head=T)
Meta_E_E <-credplot.gg(d) +xlim( "Summary_Weighted",
"Summary_Unweighted",
"Rudolf & Wendt (2014)",
"Weiner (1981)",
"Williams (1991)",
"Powell & Elbert (1984)",
"Gierut & Champion (1999)",
"Gierut et al. (1996)",
"Schmidt & Meyers (1995)",
"Gierut, Elbert & Dinnsen (1987)",
"Powell et al. (1998)",
"Gierut (1992)",
"Gierut (1991)",
"Williams (2000)",
"Gierut & Neumann (1992)",
"Miccio et al (2000)",
"Gierut et al (1990)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment