How do I add a vertical line at OR = 1 to this forest plot?

54 Views Asked by At

How do I add a vertical line at OR = 1 to this forest plot?

base_data <- tibble::tibble(mean = c(3.21, 4.09, 3.96, 1.04, 2.82),
                            lower = c(2.66, 3.34, 2.97, 0.72, 1.68),
                            upper = c(3.90, 5.05, 5.39, 1.55, 5.13),
                            race = c("Hispanic/Latino", "Black", "Asian", "NA/AN", "Multiracial"),
                            aOR = c("3.21 (2.66, 3.90)", "4.09 (3.34, 5.05)", "3.96 (2.97, 5.39)", "1.04 (0.72, 1.55)", "2.82 (1.68, 5.13)"))

base_data |>
  forestplot(labeltext = c(race, aOR),
             clip = c(0.50, 5.50),
             xlog = FALSE) |>
  fp_set_style(box = "black",
               line = "black") |>
  fp_add_header(race = c("Race/Ethnicity"),
                aOR = c("Adjusted OR")) 

Thanks so much for your help!

1

There are 1 best solutions below

0
On

I think that's what zero = of forestplot was designed for. Just add a line zero = 1:

base_data |>
  forestplot(
    labeltext = c(race, aOR),
    clip = c(0.50, 5.50),
    zero = 1,
    xlog = FALSE
  ) |>
  fp_set_style(
    box = "black",
    line = "black"
  ) |>
  fp_add_header(
    race = c("Race/Ethnicity"),
    aOR = c("Adjusted OR")
  )

enter image description here