rr-forestplot

Trying to create bold label in forestplot function


I am trying to create a bold label in the forrest plot function but have struggled. I have created my forrest plot with a table. Would appreciate any help. My code is below.

library(forestplot)

Fatigue_all_grade_sensitivity_analysis <- tibble::tibble(mean  = c(1.41, 1.52, 2.92, 1.75),
                                                lower = c(1.30, 1.44, 2.59, 1.50),
                                                upper = c(1.52, 1.60, 3.30, 2.04),
                                                study = c("Prior or concurrent docetaxecel       use", "Single agent", "Double agent", "All Studies"),
                                                n = c("8117", "15381", "1945", "17326"),
                                                RCT = c("8", "16", "1", "18"),
                                                p = c("<0.01", "<0.01", "<0.01", "<0.01"),
                                                RR = c("1.41 (1.30-1.52)", "1.52 (1.44-           1.60)", "2.92 (2.59-3.30)", "1.75 (1.50-2.04)"))

plot <- Fatigue_all_grade_sensitivity_analysis |>
forestplot(labeltext = c(study, RCT, n,  RR, p), clip = c(0.5, 3.5), 
         xlog = FALSE, lwd.zero=0.5, vertices = FALSE, boxsize = 0.08, title= "All Grade
Fatigue Events") |>
fp_set_style(box = "darkgreen",
           line = "black") |> 
fp_add_header(study = c("", "Sensitivity Analysis"),
            RCT = c("", "RCT"),
            n = c("", "n"),
            p = c("", "p"),
            RR = c("", "RR (95% CI)")) |> 
fp_decorate_graph(graph.pos = 4, right_bottom_txt = fp_txt_gp("Favours agent", gp = gpar(cex = .9)),
              left_bottom_txt = fp_txt_gp("Favours Control", gp = gpar(cex = .9))) |>

print(plot)

Solution

  • Please check if this works. I used fp_append_row, we need to update is.summary=T, if FALSE it will not make the row bold, only for TRUE it will make it bold, but the appearance of the boxplot will be black and its shape will be diamond

    library(forestplot)
    #> Warning: package 'forestplot' was built under R version 4.2.3
    #> Loading required package: grid
    #> Loading required package: checkmate
    #> Loading required package: abind
    
    Fatigue_all_grade_sensitivity_analysis <- tibble::tibble(mean  = c(1.41, 1.52, 2.92),
                                                             lower = c(1.30, 1.44, 2.59),
                                                             upper = c(1.52, 1.60, 3.30),
                                                             study = c("Prior or concurrent docetaxecel       use", "Single agent", "Double agent"),
                                                             n = c("8117", "15381", "1945"),
                                                             RCT = c("8", "16", "1"),
                                                             p = c("<0.01", "<0.01", "<0.01"),
                                                             RR = c("1.41 (1.30-1.52)", "1.52 (1.44-1.60)", "2.92 (2.59-3.30)"))
    
    plot <- Fatigue_all_grade_sensitivity_analysis |>
      forestplot(labeltext = c(study, RCT, n,  RR, p), clip = c(0.5, 3.5), 
                 xlog = FALSE, lwd.zero=0.5, vertices = FALSE, boxsize = 0.08, title= "All Grade
    Fatigue Events") |>
      fp_set_style(box = "darkgreen",
                   line = "black") |> 
      fp_add_header(study = c("", "Sensitivity Analysis"),
                    RCT = c("", "RCT"),
                    n = c("", "n"),
                    p = c("", "p"),
                    RR = c("", "RR (95% CI)")) |> 
      fp_decorate_graph(graph.pos = 4, right_bottom_txt = fp_txt_gp("Favours agent", gp = gpar(cex = .9)),
                        left_bottom_txt = fp_txt_gp("Favours Control", gp = gpar(cex = .9))) |>
      fp_append_row(mean  = 1.75,
                    lower = 1.50,
                    upper = 2.04,
                    study = "All Studies",
                    RR = "1.75 (1.50-2.04)",
                    n="17326",
                    RCT="18",
                    p="<0.01",
                    is.summary = T) |>
      
      print(plot)
    

    Created on 2023-07-16 with reprex v2.0.2