[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
Wed Sep 26 16:15:54 CEST 2018

Dear Roberto,

help(png) shows that 'width' and 'height' are by default in pixels, so as far as I can tell, you are trying to create a plot that is 8 pixels wide.


-----Original Message-----
From: P. Roberto Bakker [mailto:robertobakker using gmail.com] 
Sent: Wednesday, 26 September, 2018 11:08
To: Viechtbauer, Wolfgang (SP)
Cc: r-sig-meta-analysis using r-project.org
Subject: Re: [R-meta] metafor forest 'ylim()': 1.row distances change, 2 .relative lines?

Hi Wolfgang,

Thank you for you information.

I did the following but I receive the message "Error in plot.new() : figure margins too large"
What should I do? Thank you in advance, Roberto

datsub <- subset(dat, type == "MAOI")
res.res <- rma(measure="SMCC", yi=yi, vi=vi, data=datsub, digits=2, method = "REML")

res <- 200 # pixels per inch - Roberto: I did not know which number so I chose 200
fact <- par("mai")[1]/par("mar")[1] # calculate inches per line
### this following part is copied from inside the forest()-function.
# forest() modifies the margin internally in the same way.
par.mar <- par("mar")
par.mar.adj <- par.mar - c(0, 3, 1, 1) #Roberto: I changed the number of the vector 'c()' but the abovementioned message keeps coming back
par.mar.adj[par.mar.adj < 0] <- 0
ylim <- c(-1.5, length(datsub$yi)+3)  #In the webpage I could not find 'ma$' as mentioned in syntax; I suppose it should be the database
ylim.abs <- abs(ylim[1])+abs(ylim[2])-length(datsub$yi) # calculate absolute distance of ylim-argument
pixel.bottom <- (par.mar.adj[1])*fact*res # calculate pixels to add to bottom and top based on the margin that is internally used by forest().
pixel.top <- (par.mar.adj[3])*fact*res
    height=((length(datsub$yi)+ylim.abs)*fact*res) + pixel.bottom + pixel.top, 
par(mar=par.mar) # make sure that inside the new device the margins you want to define are actually used.
forest(res.res, slab = paste(datsub$npd, datsub$tn, sep = ", "), xlab = "", 
       cex =0.45, cex.lab=0.8, cex.main=0.8, main="MAOI vs placebo - REML - R=0.5", showweights = T, addfit= T, order=order(datsub$name),

More information about the R-sig-meta-analysis mailing list