[R] Greek symbols in study labels and custom summary lines in forest plot (meta)

David Winsemius dwinsemius at comcast.net
Wed Jul 31 19:02:22 CEST 2013


On Jul 29, 2013, at 11:52 AM, Rapsomaniki, Eleni wrote:

> Dear R helpers,
> 
> Is there a way to display mathematical notations (e.g. greek characters, subscripts) properly in study (studlab) and group (byvar) labels in a forest plot created using the meta package?
> 
> #Example:
> library(meta)
> logHR <- log(runif(10,0.5,2))
> selogHR <- log(runif(10,0.05,0.2))
> study=c(0.1,.2,.3,.4,.5,0.1,.2,.3,.4,.5)
> group=c(rep('alpha',5),rep('beta',5))
> meta1=metagen(logHR, selogHR, sm="HR",studlab=paste("Fixed",expression(beta[w]),study),byvar=group)
> forest(meta1, print.byvar=F)

I tried a variety of plotmath and substitute strategies but the arguments to studlab get first processed with 'as.character' and then put into a data.frame before printing. Dataframes do not accept language objects, so R expressions could not be processed.

> dftest <- data.frame(a =expression(a,b,c))
Error in as.data.frame.default(x[[i]], optional = TRUE) : 
  cannot coerce class ""expression"" to a data.frame


Best I could to was '

   ... ,studlab=paste('Fixed ß[w]=',study), ....

> 
> Question 2
> Is there a way to add a line to this plot at my preferred location? For example, I want to add a within-group combined estimate line (the default here is just an overall group line by random or fixed effects). 
> I know I need to use grid.lines, e.g.
> 
> grid.lines(x = 3, y = c(0.5,1),gp = gpar(col = 5))
> 
> But for the life of me I can't work out the co-ordinate system in grid graphics!

Unfortunately all of the printing to the device is handled inside the 'forest' function and no list representation is returned as a value to be augmented and later printed. So the input data would need to be entered in a manner that gets processed as text or you would need to modify the code. I don't have the knowledge of the meta package that can get there.

-- 
David Winsemius
Alameda, CA, USA



More information about the R-help mailing list