Forest plot problems

Hi,

I have some trouble with a forest plot I'm trying to produce. It is the first time I use R to produce a figure. I have the following code:

#install.packages("metafor")
library(metafor)

data2<- read.table(text ="
variable,cases,or,lower,upper
Water,642 (15%),1,1,1
Coca cola,648 (14%),0.97,0.86,1.09
Fanta,611 (12%),0.79,0.70,0.89
",
sep = ",", header = T)

data2$variable<-as.character(data2$variable)
data2$cases<-as.character(data2$cases)


data2=data2[order(nrow(data2):1),]
sapply(data2,class)

windows(height=8,width=13,rescale="fixed")
par(mar=c(4,4,1,2))


data2$hr_ul <- paste(format(data2$or,digits=3)," [",format(data2$lower,digits=3)," - ",format(data2$upper,digits=3),"]",sep="")
data2$hr_ul <- as.character(data2$hr_ul)

data2[3,"hr_ul"] <- "Ref."


forest(log(data2$or),
       ci.lb=log(data2$lower), 
       ci.ub=log(data2$upper),
       xlim=c(-10, 10),
       pch=16,
       at=log(c(0.5,1,2)),
       annotate=F,
       atransf=exp,
       slab=data2$variable,
       ilab=cbind(data2$cases,data2$hr_ul),
       ilab.xpos=c(-4,3), 
       ilab.pos=4, #How to align? 2:right, 4:left, 3:center
       cex=1.5,
       ylim=c(28, 39),
       #order=order(data2$group),
       rows=c(28.5,30,31.5),    
       xlab="Odds ratio [95% CI] (log scale)",     
       alim=log(c(0.1,10)),
       psize=1,
       refline=log(1))

### add column headings to the plot
text(-5.7, 34, cex=1.5, font=2, "Monthly intake, N (%)")
#text(-2.8, 37.6, cex=1.3, font=2, "Unadjusted HR")
text(4, 34, cex=1.5, font=2, "Odds ratio\n[95% CI]")

I have two questions:

  1. How do I zoom in on the small axis (the log scale, 0.5-2)? By changing the "at=log(c(0.5,1,2)) does make it larger but with my small odds ratios it does not really matter. I want to keep the same axis (0.5,1,2 as it makes sense) but I still want it larger in appearance.

  2. How do I make the horizontal line (the one above "Monthly intake" and "Odds ratio [95% CI]") go below the text? So the lines fit with the text.

Thanks in advance!

All best
/M

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.