Skip to content
Prev 2408 / 5636 Next

[R-meta] Setting new default layout for forest plots

Dear Magali

Well, Guido seems to be off-line so here are some suggestions.

I do not use the package in question but it seems that a bit of R 
programming might help. To save spce I only do this for a subset of your 
parameters and I have not tested it.

Option 1
Suppose we just wanted to fix digits=2. Define a new function

myforest <- function(x, mydigits = 2, ...) {
   res <- forest(x, digits = mydigits, ...)
    res
}

So the new function defaults mydigits to 2 and then calls forest with 
that set. So myforest(x) should do what you want. Obviousl you also need 
to have mycomb.random, myprediction, and so on. Note you need the ... to 
be able to pass further parameters into the function.


Option 2
Put all your values of x into a list then go

res <- lappaly(listofx, function(x) {forest (x, digits=2, comb.random=T, 
prediction=F, just="center", type.study="square", type.random="diamond", 
col.study="black", col.square="red", col.square.lines="red", 
col.inside="black", col.diamond="black", col.diamond.lines="black", 
col.predict="black", col.predict.lines="black", col.by="black", 
col.label.right="black", col.label.left="black", lty.random=0, addrow=T, 
addrow.subgroups=T, addrow.subgroups.overall=T, addrow.overall=T, 
text.random="Total", hestat=TRUE, calcwidth.hetstat = TRUE, 
test.subgroup=T, subgroup=T, test.effect.subgroup.random=T, 
test.overall.random=T, resid.hetstat=F, colgap="0.3cm", digits.tau2=1, 
calcwidth.random=T, leftcols=c("studlab", "n.e", "n.c", "effect", "ci", 
"w.random"), rightscols=NULL, allstudies=F, print.byvar=F)
}
)

then res will contain a list of the results so you can print them one by 
one.

As I say these are completely untested and may not work but might give 
you ideas about the structure of a solution.

Michael
On 14/10/2020 09:30, Magali Leyvraz wrote: