Search code examples
rr-forestplot

How to make extra line of text using text.addline1 bold using the meta package?


I am creating forest plots using the meta package in R. I have added a line of text using text.addline1 (see bottom of plot). How do I make that text bold? It says see "gpar" in the cran documentation but I can't work it out.

library(meta)

## make data

df1 <- data.frame(matrix(, nrow=14, ncol=6))
colnames(df1) <- c("estimate",  "std.error", "N", "study", "Exposure", "or" )
df1$estimate <- c("1.0588634", "1.0210044", "1.0484577", "0.9872621", "1.0122652",
                  "0.9934573", "0.9429622", "1.0320382", "0.9654555", "1.0499671", "1.0400071",
                  "1.0208341", "0.9954885", "0.9879208")
df1$std.error <- c(0.054092871, 0.037674050, 0.093067276, 0.054198110, 0.008714173, 0.010266589,
                   0.056993648, 0.058017078, 0.058050610, 0.089878607, 0.056951120, 0.011041428,
                   0.013533755, 0.090526260)
df1$N <- 500
df1$study <- "Study"
df1$Exposure <- "Smoker"
df1$Exposure[7:14] <- "Non smoker"
df1$or <- c(0.057196058,  0.020786829,  0.047320225, -0.012819723,  0.012190549, -0.006564245,
            -0.058729114,  0.031535708, -0.035155279, 0.048758876,  0.039227559, 0.020620087,
            -0.004521733, -0.012152786)

meta_obj <- metagen(or, std.error, sm = "OR", data = df1,
                       studlab = study, comb.fixed = TRUE, comb.random = FALSE, byvar = Exposure)


# FOREST ------------------------------------------------------------------

forest(meta_obj, smlab = "Text here", spacing = 1.5,
       xlab = "Odds ratio",
       xlim = c(0.5, 2),
       leftcols = c("studlab", "N"),
       col.diamond = "red", col.by = "black",
       overall.hetstat = FALSE,
       print.I2 = TRUE, print.tau2 = FALSE, 
       subgroup = T, overall = F,
       text.addline1 = "HOW DO I MAKE THIS BOLD?",
       ref = 1)

forest


Solution

  • See argument 'ff.addline':

    forest(meta_obj, smlab = "Text here", spacing = 1.5,
           xlab = "Odds ratio",
           xlim = c(0.5, 2),
           leftcols = c("studlab", "N"),
           col.diamond = "red", col.by = "black",
           overall.hetstat = FALSE,
           print.I2 = TRUE, print.tau2 = FALSE, 
           subgroup = T, overall = F,
           ref = 1,
           text.addline1 = "USE ARGUMENT 'ff.addline = \"bold\"'",
           ff.addline = "bold",
           fs.addline = 12,
           colgap.left = "2.8cm")