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

Michael Dewey ||@t@ @end|ng |rom dewey@myzen@co@uk
Fri Oct 16 14:29:00 CEST 2020


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:
> Dear Prof Schwarzer,
> 
> I am using your package meta (which is really great by the way!) and I have to compile a lot of forest plots with all the same layouts. I would like to avoid having to repeat the graphical arguments for each new forest plot, kind of like for settings.meta where you can specify the default settings and don’t need to reset again every time. I’ve tried several ways but with no success so far. I was thinking one solution would be to create a new layout (additional to ‘meta’, ‘JAMA’, ‘RevMan5’, ‘subgroup’).Would you be able to help me?
> 
> Here’s an example of the graphical arguments I would like:
> 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)
> 
> I tried:
> mylayout<-'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’
> forest(x, mylayout)
> 
> But get the error message:
> Error in forest.meta(x, mylayout) :
>    Number of studies in object 'x' and argument 'sortvar' have different length.
> 
> I also tried:
> mylayout<-'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’
> forest(x, layout=“mylayout”)
> 
> But get the error message:
> Error: Argument 'layout' must be "meta", "RevMan5", "JAMA", or "subgroup”.
> 
> Many thanks in advance for your help, best regards,
> 
> Magali
> 
> _______________________________________________
> R-sig-meta-analysis mailing list
> R-sig-meta-analysis using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
> 

-- 
Michael
http://www.dewey.myzen.co.uk/home.html



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