Erin Z
Erin Z

Reputation: 35

R forestplot does not allow expressions in labeltext with is.summary?

I am using forestplot and would like a superscript in one of my column names. An example of something like this is provided in the forestplot vignette, which I have reproduced below (changing the column name from expression(beta) to my desired expression(pseudo~R^2)).

data(HRQoL)
clrs <- fpColors(box="royalblue",line="darkblue", summary="royalblue")
tabletext <- 
  list(c(NA, rownames(HRQoL$Sweden)),
   append(list(expression(pseudo~R^2)), sprintf("%.2f", HRQoL$Sweden[,"coef"])))
forestplot(tabletext, 
       rbind(rep(NA, 3), 
             HRQoL$Sweden),
       col=clrs, 
       is.summary=c(TRUE,FALSE,FALSE,FALSE,FALSE),
       xlab="EQ-5D index")

Click here for image

This works fine, though in my plot I would like to specify is.summary. Doing do, however, messes up the position/alignment of the expression.

forestplot(tabletext, 
       rbind(rep(NA, 3), 
             HRQoL$Sweden),
       col=clrs, 
       is.summary=c(TRUE,FALSE,FALSE,FALSE,FALSE),
       xlab="EQ-5D index")

Click here for poorly-aligned image

Is there a way around this? Can I have my expression() and my is.summary too?

Upvotes: 2

Views: 863

Answers (1)

Max Gordon
Max Gordon

Reputation: 5467

I previously had an issue with the expressions positioning and therefore all of these were centered. I've fixed the issue in the dev-branch (v. 1.5.2), use devtools for installing:

devtools::install_github("gforge/forestplot", ref="develop")

Upvotes: 2

Related Questions