# [R-meta] metafor forest 'ylim()': 1.row distances change, 2 .relative lines?

Viechtbauer, Wolfgang (SP) wolfg@ng@viechtb@uer @ending from m@@@trichtuniver@ity@nl
Sun Sep 23 19:28:10 CEST 2018

```Maybe this helps -- go through this line by line.

yi <- c(.1, .3, .2, .5)
vi <- rep(.01, 4)
res <- rma(yi, vi)
forest(res)

### default for ylim is -1.5 to k+3
### summary polygon in y=-1
### line in y=0
### studies in y=1 to k
### line in y=k+1
forest(res, ylim=c(-1.5,res\$k+3))
text(0, -1:7, -1:7)

### change ylim
forest(res, ylim=c(-3,10))
text(0, -3:10, -3:10)

### this creates more space which we indicate subgroups and/or to add extra summary polygons
forest(res, ylim=c(-3,10), row=c(6,5,2,1))
text(0, -3:10, -3:10)
text(par()\$usr[1], 7, "Group A", font=2, pos=4)
text(par()\$usr[1], 3, "Group B", font=2, pos=4)
addpoly(rma(yi, vi, subset=1:2), row=-2, mlab="Group A")
addpoly(rma(yi, vi, subset=3:4), row=-3, mlab="Group A")

Best,
Wolfgang

-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On Behalf Of P. Roberto Bakker
Sent: Sunday, 23 September, 2018 12:01
To: r-sig-meta-analysis using r-project.org
Subject: [R-meta] metafor forest 'ylim()': 1.row distances change, 2 .relative lines?

Hi

When I change 'ylim()', two things happen that I do not understand:

1) The study row distances change:
- e.g. When I change from 'ylim=c(-1, 23)' into 'ylim=c(-1, 10)',  then
'y=c(-1, 5)', etc
-> the study row distances increase at every step
This whould not be a problem if I had only one forest plot - but I have
several forest plots - so between forestplots the study row distances are
different.
'rows=c()' could be a solution, however, the study row distances between
forestplots still may differ.

2. The position of both horizontal lines change when I change one.
e.g. at every step shown aboven the lower line changes position - the
summary polygon may even disappear

All in all, I seems to me that 'ylim()' zooms in/out at every change.

In short: when I change one thing 'all other things change'.

I hope I am clear.

Syntax:
forest(res, slab = paste(datsub\$npd, datsub\$tn, sep = ", "),
cex =0.45, cex.lab=0.8, cex.main=0.8, main="MAOI vs placebo - REML
- R=0.5",
showweights = TRUE, order=order(datsub\$name),
ylim=c(-1,23))

On my laptop: surface pro 4 64b
R version 3.5.0 (2018-04-23) -- "Joy in Playing"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

```