Function converts a gtsummary object to a huxtable object. A user can use this function if they wish to add customized formatting available via the huxtable functions. The huxtable package supports output to PDF via LaTeX, as well as HTML and Word.

  include = everything(),
  return_calls = FALSE,
  strip_md_bold = FALSE



Object created by a function from the gtsummary package (e.g. tbl_summary or tbl_regression)


Commands to include in output. Input may be a vector of quoted or unquoted names. tidyselect and gtsummary select helper functions are also accepted. Default is everything().


Logical. Default is FALSE. If TRUE, the calls are returned as a list of expressions.


When TRUE, all double asterisk (markdown language for bold weight) in column labels and spanning headers are removed.


A huxtable object


The as_hux_table() takes the data frame that will be printed, converts it to a huxtable and formats the table with the following huxtable functions:

  1. huxtable::huxtable()

  2. huxtable::insert_row() to insert header rows

  3. huxtable::set_left_padding() to indent variable levels

  4. huxtable::add_footnote() to add table footnotes and source notes

  5. huxtable::set_bold() to bold cells

  6. huxtable::set_italic() to italicize cells

  7. huxtable::set_top_border() add horizontal line (when indicated)

  8. huxtable::set_na_string() to use an em-dash for missing numbers

  9. huxtable::set_markdown() use markdown for header rows

  10. huxtable::set_align() to set column alignment

Any one of these commands may be omitted using the include= argument.

See also

Other gtsummary output types: as_flex_table(), as_gt(), as_kable_extra(), as_kable(), as_tibble.gtsummary()


David Hugh-Jones


trial %>%
  dplyr::select(trt, age, grade) %>%
  tbl_summary(by = trt) %>%
  add_p() %>%
#>           Characteristic   Drug A, N = 98   Drug B, N = 102   p-value  
#>         ───────────────────────────────────────────────────────────────
#>           Age               46 (37, 59)       48 (39, 56)       0.7    
#>           Unknown                7                 4                   
#>           Grade                                                 0.9    
#>           I                   35 (36%)         33 (32%)                
#>           II                  32 (33%)         36 (35%)                
#>           III                 31 (32%)         33 (32%)                
#>         ───────────────────────────────────────────────────────────────
#>           Median (IQR); n (%)                                          
#>           Wilcoxon rank sum test; Pearson's Chi-squared test           
#> Column names: label, stat_1, stat_2, p.value