Skip to content

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

2 messages · Eleni Rapsomaniki, David Winsemius

#
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)

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!

Thank you for ANY help or tips! I've run out of things to try :(

Eleni

Eleni Rapsomaniki
Research Associate/Statistics, PhD
Clinical Epidemiology Group
Department of Epidemiology and Public Health 
University College London Medical School
1 day later
#
On Jul 29, 2013, at 11:52 AM, Rapsomaniki, Eleni wrote:

            
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.
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), ....
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.