Search code examples
rr-forestplot

How to add a second vertical line in R package forestplot


I'd like to distinguish between statistical significance (OR = 1.0) and clinical significance (OR = 1.5) in my forest plot. I created this plot using the forestplot package, sample code below. Is adding a vertical line possible (while maintaining the line of no difference)?

library(forestplot)
test_data <- structure(list(
   mean = c(NA, NA, 1, 0.5, 2),
   lower = c(NA, NA, .5, .25, 1.5),
   upper = c(NA, NA, 1.5, .75, 2.5)),
   .Names = c("mean", "lower", "upper"),
   row.names = c(NA, -5L),
   class = "data.frame")

tabletext <- cbind(
   c("", "Outcome", "Outcome 1", "Outcome 2", "Outcome 3"),
   c("", "OR", "1 (0.5 - 1.5)", "0.5 (0.25 - 0.75)", "2.0 (1.5 - 2.5)"))

forestplot(tabletext,
       test_data,
       new_page = TRUE,
       xlog = TRUE,
       boxsize = .25
       )

Solution

  • Is this what you were looking for?

    forestplot(tabletext,
           test_data,
           new_page = TRUE,
           xlog = TRUE,
           grid = structure(c(log(1.5)), 
                            gp = gpar(lty = 2, col = "#CCCCFF")), 
           zero = 1,
           boxsize = .25)