Closed shannonpileggi closed 1 year ago
Hmmm, trying to think of a reasonable solution here....there are some that would surely rely on the huxtable default behavior? You can avoid the default formatting in huxtable by specifying the format of the header.
modify_header(all_stat_cols() ~ "**{level}** \nN = {style_number(n)}")
Also, we can update the PCCTC gtsummary theme to change the default header to have the line break between the level and the Ns and to style the Ns. Perhaps that is the best way around this at this point? What do you think @shannonpileggi ?
library(gtsummary)
n <- 2642
df_ex <- dplyr::tibble(
var1 = rep(1, n),
var2 = c(rep("A", n/2), rep("B", n/2))
)
df_ex |>
tbl_summary(by = var2) |>
modify_header(all_stat_cols() ~ "**{level}** \nN = {style_number(n)}") |>
as_hux_table()
#> Warning in knit_print.huxtable(x, ...): Unrecognized output format "gfm-yaml". Using `to_screen` to print huxtables.
#> Set options("huxtable.knitr_output_format") manually to "latex", "html", "rtf", "docx", "pptx", "md" or "screen".
Characteristic AN = 1,321 BN = 1,321
────────────────────────────────────────────────
var1 1,321 (100%) 1,321 (100%)
────────────────────────────────────────────────
n (%)
Column names: label, stat_1, stat_2
Created on 2023-02-17 with reprex v2.0.2
I agree, let's move the solution to croquet.
When using
modify_header()
intbl_summary()
with hux functions, likeas_hux_table()
oras_hux_xlsx()
, larger sample sizes get converted to scientific notation.A hacky fix for this is to use
huxtable::set_number_format(NA)
.Column names: label, stat_1, stat_2
Column names: label, stat_1, stat_2
Created on 2023-02-17 with reprex v2.0.2