Search code examples
rgtsummary

Deleting specific footnote in gtsummary


How can I delete specific footnote in the gtsummary table. For example I would to delete footnote 2 Wilcoxon rank sum test; Pearson's Chi-squared test but leave the other one.

library(gtsummary)
library(dplyr)

trial[c("age", "grade", "trt")] %>%
  tbl_summary(by = trt, missing = "no") %>%
  add_p()


Solution

  • You'll want to use the modify_footnote() function to remove the footnotes. Example below!

    library(gtsummary)
    packageVersion("gtsummary")
    #> [1] '1.5.0'
    
    tbl <- 
      trial[c("age", "grade", "trt")] %>%
      tbl_summary(by = trt, missing = "no") %>%
      add_p() %>%
      # remove footnotes
      modify_footnote(c(all_stat_cols(), p.value) ~ NA)
    

    enter image description here Created on 2021-11-19 by the reprex package (v2.0.1)