diff --git a/01_line_breaks.qmd b/01_line_breaks.qmd index aecb19d..3917129 100755 --- a/01_line_breaks.qmd +++ b/01_line_breaks.qmd @@ -29,6 +29,8 @@ gt_table <- tbl$table_body |> stat_2 = gt::md("**Drug B** \nManual Line Break") ) |> gt::tab_header(gt::md("This is the Title \nwith a linebreak"), subtitle = "This is the Subtitle") + +gt_table ``` ### gt_save PDF @@ -54,7 +56,6 @@ gt_table ``` ###### Preview the Output - ![](outputs/pdf/linebreaks_rmd_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -90,7 +91,6 @@ doconv::docx2pdf("outputs/docx/linebreaks_qmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/linebreaks_qmd_word.pdf){width="80%" height="1000"} | | Date | Finding | diff --git a/02_indentation.qmd b/02_indentation.qmd index 267972c..100d423 100755 --- a/02_indentation.qmd +++ b/02_indentation.qmd @@ -24,6 +24,8 @@ gt_table <- tbl$table_body |> locations = gt::cells_body(columns = label, rows = row_type %in% "missing"), fn = function(x) paste0(strrep("\U00A0", times = 4), x) ) + +gt_table ``` ### gt_save PDF diff --git a/03_spanning_header.qmd b/03_spanning_header.qmd index 15ccaea..78536ee 100755 --- a/03_spanning_header.qmd +++ b/03_spanning_header.qmd @@ -18,6 +18,8 @@ gt_table <- tbl$table_body |> gt::tab_spanner(gt::md("**Spanning Level 2**"), columns = gtsummary::all_stat_cols(), level = 2L, id = "stat_1_L2") |> gt::tab_spanner(gt::md("**Spanning Level 1**"), columns = gtsummary::all_stat_cols(FALSE), level = 1L, id = "stat_1_L1") |> gt::tab_spanner(gt::md("**Both Treatments**"), columns = stat_0, level = 1L, id = "stat_0_L1") + +gt_table ``` ### gt_save PDF @@ -57,7 +59,6 @@ doconv::docx2pdf("outputs/docx/spanning_header_gt_word.docx") ``` ###### Preview the Output - ![](outputs/docx/spanning_header_gt_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -73,7 +74,6 @@ doconv::docx2pdf("outputs/docx/spanning_header_qmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/spanning_header_qmd_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -89,7 +89,6 @@ doconv::docx2pdf("outputs/docx/spanning_header_rmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/spanning_header_rmd_word.pdf){width="80%" height="1000"} | | Date | Finding | diff --git a/04_footnotes.qmd b/04_footnotes.qmd index 89685f3..6a9e32d 100755 --- a/04_footnotes.qmd +++ b/04_footnotes.qmd @@ -19,6 +19,8 @@ gt_table <- tbl$table_body |> gt::tab_footnote("Footnote in Spanning Header", locations = gt::cells_column_spanners(spanners = "stat_1_L1")) |> gt::tab_footnote("Footnote in Subtitle", locations = gt::cells_title("subtitle")) |> gt::tab_footnote("Footnote in Title", locations = gt::cells_title("title")) + +gt_table ``` ### gt_save PDF @@ -42,7 +44,6 @@ gt_table ``` ###### Preview the Output - ![](outputs/pdf/footnotes_rmd_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -58,7 +59,6 @@ doconv::docx2pdf("outputs/docx/footnotes_gt_word.docx") ``` ###### Preview the Output - ![](outputs/docx/footnotes_gt_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -72,7 +72,6 @@ gt_table # converting word to pdf locally doconv::docx2pdf("outputs/docx/footnotes_qmd_word.docx") ``` - ###### Preview the Output ![](outputs/docx/footnotes_qmd_word.pdf){width="80%" height="1000"} @@ -90,7 +89,6 @@ doconv::docx2pdf("outputs/docx/footnotes_rmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/footnotes_rmd_word.pdf){width="80%" height="1000"} | | Date | Finding | diff --git a/05_source_notes.qmd b/05_source_notes.qmd index c3af763..38c9cdd 100755 --- a/05_source_notes.qmd +++ b/05_source_notes.qmd @@ -15,6 +15,8 @@ gt_table <- tbl$table_body |> gt::tab_source_note("This is Source Note 1") |> gt::tab_source_note("This is Source Note 2") |> gt::tab_source_note("Abbreviations: Q1 = First Quartile; Q3 = Third Quartile") + +gt_table ``` ### gt_save PDF @@ -22,7 +24,6 @@ gt_table <- tbl$table_body |> ```{r eval = FALSE} gt::gtsave(gt_table, filename = "outputs/pdf/source_notes_gt_pdf.pdf") ``` - ###### Preview the Output ![](outputs/pdf/footnotes_gt_pdf.pdf){width="80%" height="1000"} @@ -38,7 +39,6 @@ gt_table ``` ###### Preview the Output - ![](outputs/pdf/source_notes_rmd_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -54,7 +54,6 @@ doconv::docx2pdf("outputs/docx/source_notes_gt_word.docx") ``` ###### Preview the Output - ![](outputs/docx/source_notes_gt_word.docx){width="80%" height="1000"} | | Date | Finding | @@ -70,7 +69,6 @@ doconv::docx2pdf("outputs/docx/source_notes_qmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/source_notes_qmd_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -86,7 +84,6 @@ doconv::docx2pdf("outputs/docx/source_notes_rmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/source_notes_rmd_word.pdf){width="80%" height="1000"} | | Date | Finding | diff --git a/06_titles.qmd b/06_titles.qmd index 0707b69..a918fed 100755 --- a/06_titles.qmd +++ b/06_titles.qmd @@ -16,6 +16,8 @@ gt_table <- tbl$table_body |> gt::sub_missing(missing_text = "") |> # title, subtitle, and captions gt::tab_header(gt::md("This is the Title"), subtitle = "This is the Subtitle") + +gt_table ``` ### gt_save PDF @@ -25,7 +27,6 @@ gt::gtsave(gt_table, filename = "outputs/pdf/titles_gt_pdf.pdf") ``` ###### Preview the Output - ![](outputs/pdf/titles_gt_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -39,7 +40,6 @@ gt_table ``` ###### Preview the Output - ![](outputs/pdf/titles_rmd_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -55,7 +55,6 @@ doconv::docx2pdf("outputs/docx/titles_gt_word.docx") ``` ###### Preview the Output - ![](outputs/docx/titles_gt_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -72,7 +71,6 @@ doconv::docx2pdf("outputs/docx/titles_qmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/titles_qmd_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -89,7 +87,6 @@ doconv::docx2pdf("outputs/docx/titles_rmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/titles_rmd_word.pdf){width="80%" height="1000"} | | Date | Finding | diff --git a/07_alignment.qmd b/07_alignment.qmd index 3c161bd..a9d4bc2 100755 --- a/07_alignment.qmd +++ b/07_alignment.qmd @@ -3,6 +3,7 @@ title: "Alignment" format: html editor: visual --- +## Testing Alignments output ```{r eval=FALSE} @@ -14,6 +15,8 @@ gt_table <- tbl$table_body |> gt::cols_align(columns = c(stat_1, stat_2), align = "right") |> gt::cols_align(columns = c(variable, var_type), align = "center") |> gt::cols_align(columns = c(row_type, var_label), align = "left") + +gt_table ``` ### gt_save PDF diff --git a/08_text_styling.qmd b/08_text_styling.qmd index 9d2a699..ddd636d 100755 --- a/08_text_styling.qmd +++ b/08_text_styling.qmd @@ -3,9 +3,9 @@ title: "Text Styling" format: html editor: visual --- +## Testing Text Styling output ```{r eval=FALSE} - library(gtsummary) tbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = "always", label = list(age = "Age")) |> add_overall() @@ -16,6 +16,8 @@ gt_table <- tbl$table_body |> style = gt::cell_text(weight = "bold"), locations = gt::cells_body(columns = "label", rows = c(1, 3)) ) + +gt_table ``` ### gt_save PDF @@ -25,7 +27,6 @@ gt::gtsave(gt_table, filename = "outputs/pdf/bold_gt_pdf.pdf") ``` ###### Preview the Output - ![](outputs/pdf/bold_gt_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -39,7 +40,6 @@ gt_table ``` ###### Preview the Output - ![](outputs/pdf/bold_rmd_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -55,7 +55,6 @@ doconv::docx2pdf("outputs/docx/bold_gt_word.docx") ``` ###### Preview the Output - ![](outputs/docx/bold_gt_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -71,7 +70,6 @@ doconv::docx2pdf("outputs/docx/text_style_qmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/text_style_qmd_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -87,7 +85,6 @@ doconv::docx2pdf("outputs/docx/text_style_rmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/bold_rmd_word.pdf){width="80%" height="1000"} | | Date | Finding | diff --git a/09_tbl_too_long.qmd b/09_tbl_too_long.qmd index ef7c089..b2a3cb0 100755 --- a/09_tbl_too_long.qmd +++ b/09_tbl_too_long.qmd @@ -6,7 +6,7 @@ editor: visual Testing when the table is too long to fit on the page (vertical pagination). -```{r eval=FALSE} +```{r eval=T} library(gtsummary) library(dplyr) @@ -68,6 +68,8 @@ summary_table <- data %>% modify_header(label = "**Characteristic**", estimate = "**Mean (SD) or N (%)**") %>% modify_table_styling(columns = everything()) +summary_table + ``` ### gt_save PDF @@ -77,7 +79,6 @@ gt::gtsave(as_gt(summary_table), filename = "outputs/pdf/too_long_gt_pdf.pdf") ``` ###### Preview the Output - ![](outputs/pdf/too_long_gt_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -92,7 +93,6 @@ gt_table ``` ###### Preview the Output - ![](outputs/pdf/too_long_rmd_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -109,7 +109,6 @@ doconv::docx2pdf("outputs/docx/too_long_gt_word.docx") ``` ###### Preview the Output - ![](outputs/docx/too_long_gt_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -127,7 +126,6 @@ doconv::docx2pdf("outputs/docx/too_long_qmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/too_long_qmd_word.pdf){width="80%" height="1000"} | | Date | Finding | @@ -145,7 +143,6 @@ doconv::docx2pdf("outputs/docx/too_long_rmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/too_long_rmd_word.pdf){width="80%" height="1000"} | | Date | Finding | diff --git a/10_tbl_too_wide.qmd b/10_tbl_too_wide.qmd index 5b6377e..d9128fd 100755 --- a/10_tbl_too_wide.qmd +++ b/10_tbl_too_wide.qmd @@ -6,7 +6,7 @@ editor: visual Testing what happens when the table is too wide (horizontal pagination) -```{r eval=FALSE} +```{r eval=T} library(gtsummary) library(dplyr) @@ -67,6 +67,8 @@ summary_table <- data %>% modify_header(label = "**Characteristic**", estimate = "**Mean (SD) or N (%)**") %>% modify_table_styling(columns = everything()) %>% add_overall() # This adds an overall column + +summary_table ``` ### gt_save PDF @@ -76,7 +78,6 @@ gt::gtsave(as_gt(summary_table), filename = "outputs/pdf/too_wide_gt_pdf.pdf") ``` ###### Preview the Output - ![](outputs/pdf/too_wide_gt_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -90,7 +91,6 @@ summary_table ``` ###### Preview the Output - ![](outputs/pdf/too_wide_rmd_pdf.pdf){width="80%" height="1000"} | | Date | Finding | @@ -104,7 +104,6 @@ gt::gtsave(as_gt(summary_table), filename = "outputs/docx/too_wide_gt_word.docx" # converting word to pdf locally doconv::docx2pdf("outputs/docx/too_wide_gt_word.docx") ``` - ###### Preview the Output ![](outputs/docx/too_wide_gt_word.pdf){width="80%" height="1000"} @@ -138,7 +137,6 @@ doconv::docx2pdf("outputs/docx/too_wide_rmd_word.docx") ``` ###### Preview the Output - ![](outputs/docx/too_wide_rmd_word.pdf){width="80%" height="1000"} | | Date | Finding | diff --git a/11_col_widths.qmd b/11_col_widths.qmd new file mode 100644 index 0000000..6da0ce6 --- /dev/null +++ b/11_col_widths.qmd @@ -0,0 +1,84 @@ +--- +title: "Setting Column Widths" +format: html +editor: visual +--- + +## Adjusting column Widths output + +Default column width (no manipulation) +```{r eval=T} + +library(gtsummary) +tbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = "always", label = list(age = "Age")) |> add_overall() + +tbl +``` + +Using the `pct()` function within the `col_widths()` function from the {gt} package. +```{r} + +tbl <- tbl |> + as_gt()|> + gt::cols_width( + contains("label") ~ pct(70), + everything() ~ pct(30)) +tbl + +``` + +### gt_save PDF + +```{r, eval=FALSE} +gt::gtsave(tbl, filename = "outputs/pdf/col_widths_gt_pdf.pdf") +``` + +[Preview the Output](outputs/pdf/col_widths_gt_pdf.pdf) +- column width applied, all cols fit on page + +### rmarkdown rendered PDF + +```{r eval = FALSE} +tbl +``` + +[Preview the Output](outputs/pdf/col_widths_rmd_pdf.pdf) +- column width applied, table cut off after 1 col + +### quarto rendered PDF + +```{r eval = FALSE} +tbl +``` + +[Preview the Output](outputs/pdf/col_widths_qmd_pdf.pdf) +- column width applied, table cut off after 1 col + +### gt_save rendered word file + +```{r eval = FALSE} +gt::gtsave(tbl, filename = "outputs/docx/col_widths_gt_word.docx") +``` + +[Preview the Output](outputs/docx/col_widths_gt_word.docx) +- new column width isn't applied + +### quarto rendered word file + +```{r eval = FALSE} +tbl +``` + +[Preview the Output](outputs/docx/col_widths_qmd_word.docx) +- new column width isn't applied + + +### rmarkdown rendered word file + +```{r eval = FALSE} +tbl +``` + +[Preview the Output](outputs/docx/col_widths_rmd_word.docx) +- new column width isn't applied + diff --git a/11_other_engines.qmd b/12_other_engines.qmd similarity index 100% rename from 11_other_engines.qmd rename to 12_other_engines.qmd diff --git a/_quarto.yml b/_quarto.yml index 99a1ceb..eebe92e 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -39,7 +39,7 @@ knitr: website: page-navigation: true title: "Table Drawing Research" - description: "Table Engine output Experimentation" + description: "Table Engine Output Experimentation" repo-url: https://github.com/insightsengineering/table.drawing.research repo-actions: [edit, issue] @@ -80,4 +80,6 @@ website: text: Table Too Wide - href: 11_other_engines.qmd text: Other Engines + - href: 12_col_widths.qmd + text: Column Widths editor: source diff --git a/_renderdocs/col_widths.Rmd b/_renderdocs/col_widths.Rmd new file mode 100644 index 0000000..e7fedb6 --- /dev/null +++ b/_renderdocs/col_widths.Rmd @@ -0,0 +1,17 @@ +--- +output: + word_document: default + pdf_document: default +--- + +```{r echo = FALSE} +library(gtsummary) +tbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = "always", label = list(age = "Age")) |> add_overall() |> + as_gt()|> + gt::cols_width( + contains("label") ~ pct(70), + everything() ~ pct(30)) + +tbl +``` + diff --git a/_renderdocs/col_widths.qmd b/_renderdocs/col_widths.qmd new file mode 100644 index 0000000..87d39cd --- /dev/null +++ b/_renderdocs/col_widths.qmd @@ -0,0 +1,17 @@ +--- +title: "Column Widths" +format: docx +--- + +```{r echo = FALSE} +library(gtsummary) +tbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = "always", label = list(age = "Age")) |> add_overall() |> + as_gt()|> + gt::cols_width( + contains("label") ~ pct(70), + everything() ~ pct(30)) + +tbl +``` + + diff --git a/_site/outputs/docx/col_widths_gt_word.docx b/_site/outputs/docx/col_widths_gt_word.docx new file mode 100644 index 0000000..fe2a2e7 Binary files /dev/null and b/_site/outputs/docx/col_widths_gt_word.docx differ diff --git a/_site/outputs/docx/col_widths_qmd_word.docx b/_site/outputs/docx/col_widths_qmd_word.docx new file mode 100755 index 0000000..c32b685 Binary files /dev/null and b/_site/outputs/docx/col_widths_qmd_word.docx differ diff --git a/_site/outputs/docx/col_widths_rmd_word.docx b/_site/outputs/docx/col_widths_rmd_word.docx new file mode 100755 index 0000000..566d02d Binary files /dev/null and b/_site/outputs/docx/col_widths_rmd_word.docx differ diff --git a/_site/outputs/pdf/col_widths_gt_pdf.pdf b/_site/outputs/pdf/col_widths_gt_pdf.pdf new file mode 100644 index 0000000..bb83e73 Binary files /dev/null and b/_site/outputs/pdf/col_widths_gt_pdf.pdf differ diff --git a/_site/outputs/pdf/col_widths_qmd_pdf.pdf b/_site/outputs/pdf/col_widths_qmd_pdf.pdf new file mode 100755 index 0000000..24b7316 Binary files /dev/null and b/_site/outputs/pdf/col_widths_qmd_pdf.pdf differ diff --git a/_site/outputs/pdf/col_widths_rmd_pdf.pdf b/_site/outputs/pdf/col_widths_rmd_pdf.pdf new file mode 100755 index 0000000..4d7c6cc Binary files /dev/null and b/_site/outputs/pdf/col_widths_rmd_pdf.pdf differ diff --git a/docs/11_col_widths.html b/docs/11_col_widths.html new file mode 100644 index 0000000..552ad75 --- /dev/null +++ b/docs/11_col_widths.html @@ -0,0 +1,1813 @@ + + + + + + + + + +Setting Column Widths – Table Drawing Research + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Setting Column Widths

+
+ + + +
+ + + + +
+ + + +
+ + +
+

Adjusting column Widths output

+

Default column width (no manipulation)

+
+
library(gtsummary)
+tbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = "always", label = list(age = "Age")) |> add_overall()
+  
+tbl
+
+
+ + + ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacteristicOverall
N = 2001
Drug A
N = 981
Drug B
N = 1021
Age47 (38, 57)46 (37, 60)48 (39, 56)
    Unknown1174
Grade
+

+

+
    I68 (34%)35 (36%)33 (32%)
    II68 (34%)32 (33%)36 (35%)
    III64 (32%)31 (32%)33 (32%)
    Unknown000
1 Median (Q1, Q3); n (%)
+ +
+
+
+

Using the pct() function within the col_widths() function from the {gt} package.

+
+
tbl <- tbl |>
+  as_gt()|>
+  gt::cols_width(
+        contains("label") ~ pct(70),
+        everything() ~ pct(30))
+tbl
+
+
+ + + ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacteristicOverall
N = 2001
Drug A
N = 981
Drug B
N = 1021
Age47 (38, 57)46 (37, 60)48 (39, 56)
    Unknown1174
Grade
+

+

+
    I68 (34%)35 (36%)33 (32%)
    II68 (34%)32 (33%)36 (35%)
    III64 (32%)31 (32%)33 (32%)
    Unknown000
1 Median (Q1, Q3); n (%)
+ +
+
+
+
+

gt_save PDF

+
+
gt::gtsave(tbl, filename = "outputs/pdf/col_widths_gt_pdf.pdf")
+
+

Preview the Output - column width applied, all cols fit on page

+
+
+

rmarkdown rendered PDF

+
+
tbl
+
+

Preview the Output - column width applied, table cut off after 1 col

+
+
+

quarto rendered PDF

+
+
tbl
+
+

Preview the Output - column width applied, table cut off after 1 col

+
+
+

gt_save rendered word file

+
+
gt::gtsave(tbl, filename = "outputs/docx/col_widths_gt_word.docx")
+
+

Preview the Output - new column width isn’t applied

+
+
+

quarto rendered word file

+
+
tbl
+
+

Preview the Output - new column width isn’t applied

+
+
+

rmarkdown rendered word file

+
+
tbl
+
+

Preview the Output - new column width isn’t applied

+ + +
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/docs/search.json b/docs/search.json index f8c576b..7bfd1cd 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1,12 +1,30 @@ [ { +<<<<<<< HEAD + "objectID": "11_col_widths.html", + "href": "11_col_widths.html", + "title": "Setting Column Widths", + "section": "", + "text": "Default column width (no manipulation)\n\nlibrary(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n \ntbl\n\n\n\n\n\n\n\n\n\n\n\n\n\nCharacteristic\nOverall N = 2001\nDrug A N = 981\nDrug B N = 1021\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\n    Unknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\n    I\n68 (34%)\n35 (36%)\n33 (32%)\n\n\n    II\n68 (34%)\n32 (33%)\n36 (35%)\n\n\n    III\n64 (32%)\n31 (32%)\n33 (32%)\n\n\n    Unknown\n0\n0\n0\n\n\n\n1 Median (Q1, Q3); n (%)\n\n\n\n\n\n\n\n\nUsing the pct() function within the col_widths() function from the {gt} package.\n\ntbl <- tbl |>\n as_gt()|>\n gt::cols_width(\n contains(\"label\") ~ pct(70),\n everything() ~ pct(30))\ntbl\n\n\n\n\n\n\n\n\n\n\n\n\n\nCharacteristic\nOverall N = 2001\nDrug A N = 981\nDrug B N = 1021\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\n    Unknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\n    I\n68 (34%)\n35 (36%)\n33 (32%)\n\n\n    II\n68 (34%)\n32 (33%)\n36 (35%)\n\n\n    III\n64 (32%)\n31 (32%)\n33 (32%)\n\n\n    Unknown\n0\n0\n0\n\n\n\n1 Median (Q1, Q3); n (%)\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(tbl, filename = \"outputs/pdf/col_widths_gt_pdf.pdf\")\n\nPreview the Output - column width applied, all cols fit on page\n\n\n\n\ntbl\n\nPreview the Output - column width applied, table cut off after 1 col\n\n\n\n\ntbl\n\nPreview the Output - column width applied, table cut off after 1 col\n\n\n\n\ngt::gtsave(tbl, filename = \"outputs/docx/col_widths_gt_word.docx\")\n\nPreview the Output - new column width isn’t applied\n\n\n\n\ntbl\n\nPreview the Output - new column width isn’t applied\n\n\n\n\ntbl\n\nPreview the Output - new column width isn’t applied", + "crumbs": [ + "Adjust Column Width" + ] + }, + { + "objectID": "11_col_widths.html#adjusting-column-widths-output", + "href": "11_col_widths.html#adjusting-column-widths-output", + "title": "Setting Column Widths", + "section": "", + "text": "Default column width (no manipulation)\n\nlibrary(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n \ntbl\n\n\n\n\n\n\n\n\n\n\n\n\n\nCharacteristic\nOverall N = 2001\nDrug A N = 981\nDrug B N = 1021\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\n    Unknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\n    I\n68 (34%)\n35 (36%)\n33 (32%)\n\n\n    II\n68 (34%)\n32 (33%)\n36 (35%)\n\n\n    III\n64 (32%)\n31 (32%)\n33 (32%)\n\n\n    Unknown\n0\n0\n0\n\n\n\n1 Median (Q1, Q3); n (%)\n\n\n\n\n\n\n\n\nUsing the pct() function within the col_widths() function from the {gt} package.\n\ntbl <- tbl |>\n as_gt()|>\n gt::cols_width(\n contains(\"label\") ~ pct(70),\n everything() ~ pct(30))\ntbl\n\n\n\n\n\n\n\n\n\n\n\n\n\nCharacteristic\nOverall N = 2001\nDrug A N = 981\nDrug B N = 1021\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\n    Unknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\n    I\n68 (34%)\n35 (36%)\n33 (32%)\n\n\n    II\n68 (34%)\n32 (33%)\n36 (35%)\n\n\n    III\n64 (32%)\n31 (32%)\n33 (32%)\n\n\n    Unknown\n0\n0\n0\n\n\n\n1 Median (Q1, Q3); n (%)\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(tbl, filename = \"outputs/pdf/col_widths_gt_pdf.pdf\")\n\nPreview the Output - column width applied, all cols fit on page\n\n\n\n\ntbl\n\nPreview the Output - column width applied, table cut off after 1 col\n\n\n\n\ntbl\n\nPreview the Output - column width applied, table cut off after 1 col\n\n\n\n\ngt::gtsave(tbl, filename = \"outputs/docx/col_widths_gt_word.docx\")\n\nPreview the Output - new column width isn’t applied\n\n\n\n\ntbl\n\nPreview the Output - new column width isn’t applied\n\n\n\n\ntbl\n\nPreview the Output - new column width isn’t applied", +======= "objectID": "index.html", "href": "index.html", "title": "Table Drawing Research", "section": "", "text": "Overview\nTables built in {gtsummary} typically use {gt} functions to draw and render tables in different output formats. As a result, not all table customization translated correctly. This repo is used to experiment and identify potential adaptions to {gt} functions to maintain as much of the table decoration as possible when exporting to other formats. Currently exploring: HTML, PDF (with and without Typst), and Word (.docx) outputs.\nBelow is the sample {gtsummary} table with notable customizations (footnotes, headers, titles, linebreaks, indentations, etc.) we are tracking.\n\n\n\n\n\n This is the caption\n[Used for cross referencing in Quarto]\n \n \n This is the Title\nwith a linebreak1\n \n \n This is the Subtitle2\n \n \n \n \n Spanning Level 2\n \n \n \n Characteristic\n    Indented Header4\n \n Both Treatments\n \n \n Spanning Level 13\n \n \n \n Overall\n Drug A\nManual Line Break\n Drug B\nManual Line Break\n \n \n \n Age\n  linebreak in a cell5\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n       Unknown\n11\n7\n4\n Grade\n\n\n\n   I\n68 (34%)\n35 (36%)\n33 (32%)\n   II\n68 (34%)\n32 (33%)\n36 (35%)\n   III\n64 (32%)\n31 (32%)\n33 (32%)\n       Unknown\n0\n0\n0\n \n \n \n This is Source Note 1\n \n \n This is Source Note 2\n \n \n Abbreviations: Q1 = First Quartile; Q3 = Third Quartile\n \n \n \n \n 1 Footnote in Title\n \n \n 2 Footnote in Subtitle\n \n \n 3 Footnote in Spanning Header\n \n \n 4 Footnote in Header\n \n \n 5 Footnote in Body\n \n \n\n\n\n\n\nIssue Log\nHere we document things that were discovered through this output analysis with date stamps that can be updated as feature requests are addressed.\n\n\n\n\n\n\n\n\nDate\nIssue\nResolved?\n\n\n\n\n2025-03-03\nNo caption in all .docx exports\n\n\n\n2025-03-03\nTitles in .docx output (using gtsave) are left-justified (not centered with the table)\n\n\n\n2025-03-03\nLinebreaks aren’t applied to “header” content in .docx output\n\n\n\n2025-03-03\n“Table 1” text is automatically added when not supplied a title (.docx)", +>>>>>>> main "crumbs": [ - "Home" + "Adjust Column Width" ] }, { @@ -14,7 +32,21 @@ "href": "10_tbl_too_wide.html", "title": "Table Too Wide", "section": "", +<<<<<<< HEAD + "text": "library(gtsummary)\nlibrary(dplyr)\n\n\nAttaching package: 'dplyr'\n\n\nThe following objects are masked from 'package:stats':\n\n filter, lag\n\n\nThe following objects are masked from 'package:base':\n\n intersect, setdiff, setequal, union\n\nset.seed(123)\ndata <- tibble(\n id = 1:100,\n age = sample(18:90, 100, replace = TRUE),\n sex = sample(c(\"Male\", \"Female\"), 100, replace = TRUE),\n race = sample(c(\"White\", \"Black\", \"Asian\", \"Hispanic\"), 100, replace = TRUE),\n bmi = round(runif(100, 18, 35), 1),\n smoking_status = sample(c(\"Never\", \"Former\", \"Current\"), 100, replace = TRUE),\n diabetes = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n hypertension = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n heart_disease = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cancer = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cholesterol = sample(c(\"Normal\", \"High\"), 100, replace = TRUE),\n exercise_frequency = sample(0:7, 100, replace = TRUE),\n alcohol_intake = sample(c(\"None\", \"Low\", \"Moderate\", \"High\"), 100, replace = TRUE),\n family_history = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n education = sample(c(\"High School\", \"College\", \"Graduate\", \"Post-Grad\", \"Middle School\", \"Elementary School\", \"Pre School\", \"Kindergarten\"), 100, replace = TRUE),\n marital_status = sample(c(\"Single\", \"Married\", \"Divorced\"), 100, replace = TRUE),\n employment_status = sample(c(\"Employed\", \"Unemployed\", \"Retired\"), 100, replace = TRUE),\n region = sample(c(\"North\", \"South\", \"East\", \"West\"), 100, replace = TRUE),\n health_insurance = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n medication = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n visits_last_year = sample(0:10, 100, replace = TRUE),\n satisfaction = sample(1:5, 100, replace = TRUE)\n)\n\n# Create a wide summary table\nsummary_table <- data %>%\n tbl_summary(\n by = education,\n statistic = list(all_continuous() ~ \"{mean} ({sd})\", \n all_categorical() ~ \"{n} ({p}%)\"),\n label = list(\n age ~ \"Age (years)\",\n bmi ~ \"BMI\",\n smoking_status ~ \"Smoking Status\",\n diabetes ~ \"Diabetes\",\n hypertension ~ \"Hypertension\",\n heart_disease ~ \"Heart Disease\",\n cancer ~ \"Cancer\",\n cholesterol ~ \"Cholesterol\",\n exercise_frequency ~ \"Exercise Frequency (days/week)\",\n alcohol_intake ~ \"Alcohol Intake\",\n family_history ~ \"Family History\",\n marital_status ~ \"Marital Status\",\n employment_status ~ \"Employment Status\",\n region ~ \"Region\",\n health_insurance ~ \"Health Insurance\",\n medication ~ \"On Medication\",\n visits_last_year ~ \"Visits Last Year\",\n satisfaction ~ \"Health Satisfaction (1-5)\"\n )\n ) %>%\n add_n() %>%\n modify_header(label = \"**Characteristic**\", estimate = \"**Mean (SD) or N (%)**\") %>%\n modify_table_styling(columns = everything()) %>%\n add_overall() # This adds an overall column\n\nsummary_table\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nCharacteristic\nN\nOverall N = 1001\nCollege N = 81\nElementary School N = 151\nGraduate N = 101\nHigh School N = 151\nKindergarten N = 141\nMiddle School N = 131\nPost-Grad N = 121\nPre School N = 131\n\n\n\n\nid\n100\n51 (29)\n66 (30)\n47 (30)\n62 (26)\n46 (27)\n51 (28)\n60 (32)\n55 (25)\n28 (25)\n\n\nAge (years)\n100\n53 (20)\n45 (8)\n64 (20)\n54 (22)\n47 (18)\n52 (20)\n55 (19)\n51 (20)\n49 (22)\n\n\nsex\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Female\n\n\n50 (50%)\n2 (25%)\n9 (60%)\n5 (50%)\n7 (47%)\n8 (57%)\n6 (46%)\n6 (50%)\n7 (54%)\n\n\n    Male\n\n\n50 (50%)\n6 (75%)\n6 (40%)\n5 (50%)\n8 (53%)\n6 (43%)\n7 (54%)\n6 (50%)\n6 (46%)\n\n\nrace\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Asian\n\n\n16 (16%)\n0 (0%)\n5 (33%)\n1 (10%)\n2 (13%)\n4 (29%)\n0 (0%)\n2 (17%)\n2 (15%)\n\n\n    Black\n\n\n27 (27%)\n4 (50%)\n4 (27%)\n4 (40%)\n5 (33%)\n0 (0%)\n4 (31%)\n1 (8.3%)\n5 (38%)\n\n\n    Hispanic\n\n\n17 (17%)\n2 (25%)\n2 (13%)\n3 (30%)\n2 (13%)\n0 (0%)\n4 (31%)\n4 (33%)\n0 (0%)\n\n\n    White\n\n\n40 (40%)\n2 (25%)\n4 (27%)\n2 (20%)\n6 (40%)\n10 (71%)\n5 (38%)\n5 (42%)\n6 (46%)\n\n\nBMI\n100\n26.2 (4.9)\n25.2 (5.2)\n25.7 (4.4)\n28.5 (5.1)\n25.4 (5.3)\n25.8 (4.3)\n26.9 (4.6)\n27.7 (5.6)\n24.6 (5.1)\n\n\nSmoking Status\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Current\n\n\n39 (39%)\n5 (63%)\n6 (40%)\n4 (40%)\n6 (40%)\n3 (21%)\n7 (54%)\n5 (42%)\n3 (23%)\n\n\n    Former\n\n\n37 (37%)\n3 (38%)\n3 (20%)\n3 (30%)\n5 (33%)\n9 (64%)\n3 (23%)\n3 (25%)\n8 (62%)\n\n\n    Never\n\n\n24 (24%)\n0 (0%)\n6 (40%)\n3 (30%)\n4 (27%)\n2 (14%)\n3 (23%)\n4 (33%)\n2 (15%)\n\n\nDiabetes\n100\n49 (49%)\n6 (75%)\n8 (53%)\n4 (40%)\n6 (40%)\n10 (71%)\n4 (31%)\n8 (67%)\n3 (23%)\n\n\nHypertension\n100\n53 (53%)\n2 (25%)\n9 (60%)\n5 (50%)\n7 (47%)\n7 (50%)\n8 (62%)\n8 (67%)\n7 (54%)\n\n\nHeart Disease\n100\n51 (51%)\n6 (75%)\n11 (73%)\n9 (90%)\n8 (53%)\n3 (21%)\n5 (38%)\n3 (25%)\n6 (46%)\n\n\nCancer\n100\n50 (50%)\n2 (25%)\n10 (67%)\n3 (30%)\n8 (53%)\n8 (57%)\n7 (54%)\n5 (42%)\n7 (54%)\n\n\nCholesterol\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    High\n\n\n47 (47%)\n2 (25%)\n8 (53%)\n5 (50%)\n9 (60%)\n7 (50%)\n4 (31%)\n8 (67%)\n4 (31%)\n\n\n    Normal\n\n\n53 (53%)\n6 (75%)\n7 (47%)\n5 (50%)\n6 (40%)\n7 (50%)\n9 (69%)\n4 (33%)\n9 (69%)\n\n\nExercise Frequency (days/week)\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    0\n\n\n13 (13%)\n0 (0%)\n4 (27%)\n1 (10%)\n2 (13%)\n2 (14%)\n0 (0%)\n1 (8.3%)\n3 (23%)\n\n\n    1\n\n\n8 (8.0%)\n0 (0%)\n1 (6.7%)\n1 (10%)\n3 (20%)\n0 (0%)\n2 (15%)\n1 (8.3%)\n0 (0%)\n\n\n    2\n\n\n10 (10%)\n0 (0%)\n1 (6.7%)\n4 (40%)\n1 (6.7%)\n1 (7.1%)\n1 (7.7%)\n2 (17%)\n0 (0%)\n\n\n    3\n\n\n13 (13%)\n0 (0%)\n3 (20%)\n0 (0%)\n0 (0%)\n2 (14%)\n4 (31%)\n1 (8.3%)\n3 (23%)\n\n\n    4\n\n\n15 (15%)\n3 (38%)\n0 (0%)\n2 (20%)\n1 (6.7%)\n5 (36%)\n1 (7.7%)\n3 (25%)\n0 (0%)\n\n\n    5\n\n\n12 (12%)\n3 (38%)\n1 (6.7%)\n1 (10%)\n2 (13%)\n0 (0%)\n0 (0%)\n2 (17%)\n3 (23%)\n\n\n    6\n\n\n10 (10%)\n1 (13%)\n2 (13%)\n1 (10%)\n2 (13%)\n0 (0%)\n2 (15%)\n2 (17%)\n0 (0%)\n\n\n    7\n\n\n19 (19%)\n1 (13%)\n3 (20%)\n0 (0%)\n4 (27%)\n4 (29%)\n3 (23%)\n0 (0%)\n4 (31%)\n\n\nAlcohol Intake\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    High\n\n\n21 (21%)\n2 (25%)\n3 (20%)\n2 (20%)\n1 (6.7%)\n7 (50%)\n4 (31%)\n2 (17%)\n0 (0%)\n\n\n    Low\n\n\n29 (29%)\n3 (38%)\n3 (20%)\n3 (30%)\n6 (40%)\n2 (14%)\n2 (15%)\n5 (42%)\n5 (38%)\n\n\n    Moderate\n\n\n25 (25%)\n2 (25%)\n4 (27%)\n3 (30%)\n5 (33%)\n3 (21%)\n2 (15%)\n2 (17%)\n4 (31%)\n\n\n    None\n\n\n25 (25%)\n1 (13%)\n5 (33%)\n2 (20%)\n3 (20%)\n2 (14%)\n5 (38%)\n3 (25%)\n4 (31%)\n\n\nFamily History\n100\n57 (57%)\n3 (38%)\n10 (67%)\n6 (60%)\n6 (40%)\n7 (50%)\n10 (77%)\n6 (50%)\n9 (69%)\n\n\nMarital Status\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Divorced\n\n\n34 (34%)\n5 (63%)\n3 (20%)\n5 (50%)\n6 (40%)\n2 (14%)\n5 (38%)\n6 (50%)\n2 (15%)\n\n\n    Married\n\n\n38 (38%)\n2 (25%)\n5 (33%)\n3 (30%)\n7 (47%)\n8 (57%)\n3 (23%)\n3 (25%)\n7 (54%)\n\n\n    Single\n\n\n28 (28%)\n1 (13%)\n7 (47%)\n2 (20%)\n2 (13%)\n4 (29%)\n5 (38%)\n3 (25%)\n4 (31%)\n\n\nEmployment Status\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Employed\n\n\n37 (37%)\n2 (25%)\n3 (20%)\n2 (20%)\n9 (60%)\n7 (50%)\n6 (46%)\n4 (33%)\n4 (31%)\n\n\n    Retired\n\n\n35 (35%)\n5 (63%)\n3 (20%)\n4 (40%)\n3 (20%)\n5 (36%)\n5 (38%)\n5 (42%)\n5 (38%)\n\n\n    Unemployed\n\n\n28 (28%)\n1 (13%)\n9 (60%)\n4 (40%)\n3 (20%)\n2 (14%)\n2 (15%)\n3 (25%)\n4 (31%)\n\n\nRegion\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    East\n\n\n20 (20%)\n2 (25%)\n3 (20%)\n1 (10%)\n4 (27%)\n2 (14%)\n2 (15%)\n4 (33%)\n2 (15%)\n\n\n    North\n\n\n29 (29%)\n3 (38%)\n3 (20%)\n3 (30%)\n5 (33%)\n5 (36%)\n4 (31%)\n4 (33%)\n2 (15%)\n\n\n    South\n\n\n23 (23%)\n0 (0%)\n4 (27%)\n2 (20%)\n1 (6.7%)\n4 (29%)\n4 (31%)\n1 (8.3%)\n7 (54%)\n\n\n    West\n\n\n28 (28%)\n3 (38%)\n5 (33%)\n4 (40%)\n5 (33%)\n3 (21%)\n3 (23%)\n3 (25%)\n2 (15%)\n\n\nHealth Insurance\n100\n54 (54%)\n5 (63%)\n9 (60%)\n4 (40%)\n6 (40%)\n7 (50%)\n5 (38%)\n9 (75%)\n9 (69%)\n\n\nOn Medication\n100\n53 (53%)\n5 (63%)\n9 (60%)\n5 (50%)\n7 (47%)\n6 (43%)\n7 (54%)\n7 (58%)\n7 (54%)\n\n\nVisits Last Year\n100\n5 (3)\n6 (3)\n6 (3)\n6 (4)\n6 (3)\n5 (3)\n6 (3)\n5 (3)\n5 (3)\n\n\nHealth Satisfaction (1-5)\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    1\n\n\n24 (24%)\n3 (38%)\n5 (33%)\n1 (10%)\n3 (20%)\n2 (14%)\n5 (38%)\n3 (25%)\n2 (15%)\n\n\n    2\n\n\n21 (21%)\n2 (25%)\n2 (13%)\n3 (30%)\n3 (20%)\n7 (50%)\n2 (15%)\n1 (8.3%)\n1 (7.7%)\n\n\n    3\n\n\n19 (19%)\n1 (13%)\n2 (13%)\n2 (20%)\n3 (20%)\n2 (14%)\n2 (15%)\n3 (25%)\n4 (31%)\n\n\n    4\n\n\n22 (22%)\n0 (0%)\n2 (13%)\n2 (20%)\n5 (33%)\n2 (14%)\n3 (23%)\n3 (25%)\n5 (38%)\n\n\n    5\n\n\n14 (14%)\n2 (25%)\n4 (27%)\n2 (20%)\n1 (6.7%)\n1 (7.1%)\n1 (7.7%)\n2 (17%)\n1 (7.7%)\n\n\n\n1 Mean (SD); n (%)\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/pdf/too_wide_gt_pdf.pdf\")\n\nPreview the Output\n\ntable cut off at the end of the page (portrait)\n\n\n\n\n\nsummary_table\n\nPreview the Output\n\ntable cut off at the end of the page (portrait)\n\n\n\n\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/docx/too_wide_gt_word.docx\")\n\nPreview the Output - table condensed (squished) to fit on the page (text wrapping within cells)\n\n\n\n\ngt_table\n\nPreview the Output - table condensed (squished) to fit on the page (text wrapping within cells)\n\n\n\n\ngt_table\n\nPreview the Output\n\ntable condensed (squished) to fit on the page (text wrapping within cells)", + "crumbs": [ + "Table Too Wide" + ] + }, + { + "objectID": "10_tbl_too_wide.html#testing-output-when-the-table-is-too-long", + "href": "10_tbl_too_wide.html#testing-output-when-the-table-is-too-long", + "title": "Table Too Wide", + "section": "", + "text": "library(gtsummary)\nlibrary(dplyr)\n\n\nAttaching package: 'dplyr'\n\n\nThe following objects are masked from 'package:stats':\n\n filter, lag\n\n\nThe following objects are masked from 'package:base':\n\n intersect, setdiff, setequal, union\n\nset.seed(123)\ndata <- tibble(\n id = 1:100,\n age = sample(18:90, 100, replace = TRUE),\n sex = sample(c(\"Male\", \"Female\"), 100, replace = TRUE),\n race = sample(c(\"White\", \"Black\", \"Asian\", \"Hispanic\"), 100, replace = TRUE),\n bmi = round(runif(100, 18, 35), 1),\n smoking_status = sample(c(\"Never\", \"Former\", \"Current\"), 100, replace = TRUE),\n diabetes = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n hypertension = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n heart_disease = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cancer = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cholesterol = sample(c(\"Normal\", \"High\"), 100, replace = TRUE),\n exercise_frequency = sample(0:7, 100, replace = TRUE),\n alcohol_intake = sample(c(\"None\", \"Low\", \"Moderate\", \"High\"), 100, replace = TRUE),\n family_history = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n education = sample(c(\"High School\", \"College\", \"Graduate\", \"Post-Grad\", \"Middle School\", \"Elementary School\", \"Pre School\", \"Kindergarten\"), 100, replace = TRUE),\n marital_status = sample(c(\"Single\", \"Married\", \"Divorced\"), 100, replace = TRUE),\n employment_status = sample(c(\"Employed\", \"Unemployed\", \"Retired\"), 100, replace = TRUE),\n region = sample(c(\"North\", \"South\", \"East\", \"West\"), 100, replace = TRUE),\n health_insurance = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n medication = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n visits_last_year = sample(0:10, 100, replace = TRUE),\n satisfaction = sample(1:5, 100, replace = TRUE)\n)\n\n# Create a wide summary table\nsummary_table <- data %>%\n tbl_summary(\n by = education,\n statistic = list(all_continuous() ~ \"{mean} ({sd})\", \n all_categorical() ~ \"{n} ({p}%)\"),\n label = list(\n age ~ \"Age (years)\",\n bmi ~ \"BMI\",\n smoking_status ~ \"Smoking Status\",\n diabetes ~ \"Diabetes\",\n hypertension ~ \"Hypertension\",\n heart_disease ~ \"Heart Disease\",\n cancer ~ \"Cancer\",\n cholesterol ~ \"Cholesterol\",\n exercise_frequency ~ \"Exercise Frequency (days/week)\",\n alcohol_intake ~ \"Alcohol Intake\",\n family_history ~ \"Family History\",\n marital_status ~ \"Marital Status\",\n employment_status ~ \"Employment Status\",\n region ~ \"Region\",\n health_insurance ~ \"Health Insurance\",\n medication ~ \"On Medication\",\n visits_last_year ~ \"Visits Last Year\",\n satisfaction ~ \"Health Satisfaction (1-5)\"\n )\n ) %>%\n add_n() %>%\n modify_header(label = \"**Characteristic**\", estimate = \"**Mean (SD) or N (%)**\") %>%\n modify_table_styling(columns = everything()) %>%\n add_overall() # This adds an overall column\n\nsummary_table\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nCharacteristic\nN\nOverall N = 1001\nCollege N = 81\nElementary School N = 151\nGraduate N = 101\nHigh School N = 151\nKindergarten N = 141\nMiddle School N = 131\nPost-Grad N = 121\nPre School N = 131\n\n\n\n\nid\n100\n51 (29)\n66 (30)\n47 (30)\n62 (26)\n46 (27)\n51 (28)\n60 (32)\n55 (25)\n28 (25)\n\n\nAge (years)\n100\n53 (20)\n45 (8)\n64 (20)\n54 (22)\n47 (18)\n52 (20)\n55 (19)\n51 (20)\n49 (22)\n\n\nsex\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Female\n\n\n50 (50%)\n2 (25%)\n9 (60%)\n5 (50%)\n7 (47%)\n8 (57%)\n6 (46%)\n6 (50%)\n7 (54%)\n\n\n    Male\n\n\n50 (50%)\n6 (75%)\n6 (40%)\n5 (50%)\n8 (53%)\n6 (43%)\n7 (54%)\n6 (50%)\n6 (46%)\n\n\nrace\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Asian\n\n\n16 (16%)\n0 (0%)\n5 (33%)\n1 (10%)\n2 (13%)\n4 (29%)\n0 (0%)\n2 (17%)\n2 (15%)\n\n\n    Black\n\n\n27 (27%)\n4 (50%)\n4 (27%)\n4 (40%)\n5 (33%)\n0 (0%)\n4 (31%)\n1 (8.3%)\n5 (38%)\n\n\n    Hispanic\n\n\n17 (17%)\n2 (25%)\n2 (13%)\n3 (30%)\n2 (13%)\n0 (0%)\n4 (31%)\n4 (33%)\n0 (0%)\n\n\n    White\n\n\n40 (40%)\n2 (25%)\n4 (27%)\n2 (20%)\n6 (40%)\n10 (71%)\n5 (38%)\n5 (42%)\n6 (46%)\n\n\nBMI\n100\n26.2 (4.9)\n25.2 (5.2)\n25.7 (4.4)\n28.5 (5.1)\n25.4 (5.3)\n25.8 (4.3)\n26.9 (4.6)\n27.7 (5.6)\n24.6 (5.1)\n\n\nSmoking Status\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Current\n\n\n39 (39%)\n5 (63%)\n6 (40%)\n4 (40%)\n6 (40%)\n3 (21%)\n7 (54%)\n5 (42%)\n3 (23%)\n\n\n    Former\n\n\n37 (37%)\n3 (38%)\n3 (20%)\n3 (30%)\n5 (33%)\n9 (64%)\n3 (23%)\n3 (25%)\n8 (62%)\n\n\n    Never\n\n\n24 (24%)\n0 (0%)\n6 (40%)\n3 (30%)\n4 (27%)\n2 (14%)\n3 (23%)\n4 (33%)\n2 (15%)\n\n\nDiabetes\n100\n49 (49%)\n6 (75%)\n8 (53%)\n4 (40%)\n6 (40%)\n10 (71%)\n4 (31%)\n8 (67%)\n3 (23%)\n\n\nHypertension\n100\n53 (53%)\n2 (25%)\n9 (60%)\n5 (50%)\n7 (47%)\n7 (50%)\n8 (62%)\n8 (67%)\n7 (54%)\n\n\nHeart Disease\n100\n51 (51%)\n6 (75%)\n11 (73%)\n9 (90%)\n8 (53%)\n3 (21%)\n5 (38%)\n3 (25%)\n6 (46%)\n\n\nCancer\n100\n50 (50%)\n2 (25%)\n10 (67%)\n3 (30%)\n8 (53%)\n8 (57%)\n7 (54%)\n5 (42%)\n7 (54%)\n\n\nCholesterol\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    High\n\n\n47 (47%)\n2 (25%)\n8 (53%)\n5 (50%)\n9 (60%)\n7 (50%)\n4 (31%)\n8 (67%)\n4 (31%)\n\n\n    Normal\n\n\n53 (53%)\n6 (75%)\n7 (47%)\n5 (50%)\n6 (40%)\n7 (50%)\n9 (69%)\n4 (33%)\n9 (69%)\n\n\nExercise Frequency (days/week)\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    0\n\n\n13 (13%)\n0 (0%)\n4 (27%)\n1 (10%)\n2 (13%)\n2 (14%)\n0 (0%)\n1 (8.3%)\n3 (23%)\n\n\n    1\n\n\n8 (8.0%)\n0 (0%)\n1 (6.7%)\n1 (10%)\n3 (20%)\n0 (0%)\n2 (15%)\n1 (8.3%)\n0 (0%)\n\n\n    2\n\n\n10 (10%)\n0 (0%)\n1 (6.7%)\n4 (40%)\n1 (6.7%)\n1 (7.1%)\n1 (7.7%)\n2 (17%)\n0 (0%)\n\n\n    3\n\n\n13 (13%)\n0 (0%)\n3 (20%)\n0 (0%)\n0 (0%)\n2 (14%)\n4 (31%)\n1 (8.3%)\n3 (23%)\n\n\n    4\n\n\n15 (15%)\n3 (38%)\n0 (0%)\n2 (20%)\n1 (6.7%)\n5 (36%)\n1 (7.7%)\n3 (25%)\n0 (0%)\n\n\n    5\n\n\n12 (12%)\n3 (38%)\n1 (6.7%)\n1 (10%)\n2 (13%)\n0 (0%)\n0 (0%)\n2 (17%)\n3 (23%)\n\n\n    6\n\n\n10 (10%)\n1 (13%)\n2 (13%)\n1 (10%)\n2 (13%)\n0 (0%)\n2 (15%)\n2 (17%)\n0 (0%)\n\n\n    7\n\n\n19 (19%)\n1 (13%)\n3 (20%)\n0 (0%)\n4 (27%)\n4 (29%)\n3 (23%)\n0 (0%)\n4 (31%)\n\n\nAlcohol Intake\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    High\n\n\n21 (21%)\n2 (25%)\n3 (20%)\n2 (20%)\n1 (6.7%)\n7 (50%)\n4 (31%)\n2 (17%)\n0 (0%)\n\n\n    Low\n\n\n29 (29%)\n3 (38%)\n3 (20%)\n3 (30%)\n6 (40%)\n2 (14%)\n2 (15%)\n5 (42%)\n5 (38%)\n\n\n    Moderate\n\n\n25 (25%)\n2 (25%)\n4 (27%)\n3 (30%)\n5 (33%)\n3 (21%)\n2 (15%)\n2 (17%)\n4 (31%)\n\n\n    None\n\n\n25 (25%)\n1 (13%)\n5 (33%)\n2 (20%)\n3 (20%)\n2 (14%)\n5 (38%)\n3 (25%)\n4 (31%)\n\n\nFamily History\n100\n57 (57%)\n3 (38%)\n10 (67%)\n6 (60%)\n6 (40%)\n7 (50%)\n10 (77%)\n6 (50%)\n9 (69%)\n\n\nMarital Status\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Divorced\n\n\n34 (34%)\n5 (63%)\n3 (20%)\n5 (50%)\n6 (40%)\n2 (14%)\n5 (38%)\n6 (50%)\n2 (15%)\n\n\n    Married\n\n\n38 (38%)\n2 (25%)\n5 (33%)\n3 (30%)\n7 (47%)\n8 (57%)\n3 (23%)\n3 (25%)\n7 (54%)\n\n\n    Single\n\n\n28 (28%)\n1 (13%)\n7 (47%)\n2 (20%)\n2 (13%)\n4 (29%)\n5 (38%)\n3 (25%)\n4 (31%)\n\n\nEmployment Status\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    Employed\n\n\n37 (37%)\n2 (25%)\n3 (20%)\n2 (20%)\n9 (60%)\n7 (50%)\n6 (46%)\n4 (33%)\n4 (31%)\n\n\n    Retired\n\n\n35 (35%)\n5 (63%)\n3 (20%)\n4 (40%)\n3 (20%)\n5 (36%)\n5 (38%)\n5 (42%)\n5 (38%)\n\n\n    Unemployed\n\n\n28 (28%)\n1 (13%)\n9 (60%)\n4 (40%)\n3 (20%)\n2 (14%)\n2 (15%)\n3 (25%)\n4 (31%)\n\n\nRegion\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    East\n\n\n20 (20%)\n2 (25%)\n3 (20%)\n1 (10%)\n4 (27%)\n2 (14%)\n2 (15%)\n4 (33%)\n2 (15%)\n\n\n    North\n\n\n29 (29%)\n3 (38%)\n3 (20%)\n3 (30%)\n5 (33%)\n5 (36%)\n4 (31%)\n4 (33%)\n2 (15%)\n\n\n    South\n\n\n23 (23%)\n0 (0%)\n4 (27%)\n2 (20%)\n1 (6.7%)\n4 (29%)\n4 (31%)\n1 (8.3%)\n7 (54%)\n\n\n    West\n\n\n28 (28%)\n3 (38%)\n5 (33%)\n4 (40%)\n5 (33%)\n3 (21%)\n3 (23%)\n3 (25%)\n2 (15%)\n\n\nHealth Insurance\n100\n54 (54%)\n5 (63%)\n9 (60%)\n4 (40%)\n6 (40%)\n7 (50%)\n5 (38%)\n9 (75%)\n9 (69%)\n\n\nOn Medication\n100\n53 (53%)\n5 (63%)\n9 (60%)\n5 (50%)\n7 (47%)\n6 (43%)\n7 (54%)\n7 (58%)\n7 (54%)\n\n\nVisits Last Year\n100\n5 (3)\n6 (3)\n6 (3)\n6 (4)\n6 (3)\n5 (3)\n6 (3)\n5 (3)\n5 (3)\n\n\nHealth Satisfaction (1-5)\n100\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    1\n\n\n24 (24%)\n3 (38%)\n5 (33%)\n1 (10%)\n3 (20%)\n2 (14%)\n5 (38%)\n3 (25%)\n2 (15%)\n\n\n    2\n\n\n21 (21%)\n2 (25%)\n2 (13%)\n3 (30%)\n3 (20%)\n7 (50%)\n2 (15%)\n1 (8.3%)\n1 (7.7%)\n\n\n    3\n\n\n19 (19%)\n1 (13%)\n2 (13%)\n2 (20%)\n3 (20%)\n2 (14%)\n2 (15%)\n3 (25%)\n4 (31%)\n\n\n    4\n\n\n22 (22%)\n0 (0%)\n2 (13%)\n2 (20%)\n5 (33%)\n2 (14%)\n3 (23%)\n3 (25%)\n5 (38%)\n\n\n    5\n\n\n14 (14%)\n2 (25%)\n4 (27%)\n2 (20%)\n1 (6.7%)\n1 (7.1%)\n1 (7.7%)\n2 (17%)\n1 (7.7%)\n\n\n\n1 Mean (SD); n (%)\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/pdf/too_wide_gt_pdf.pdf\")\n\nPreview the Output\n\ntable cut off at the end of the page (portrait)\n\n\n\n\n\nsummary_table\n\nPreview the Output\n\ntable cut off at the end of the page (portrait)\n\n\n\n\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/docx/too_wide_gt_word.docx\")\n\nPreview the Output - table condensed (squished) to fit on the page (text wrapping within cells)\n\n\n\n\ngt_table\n\nPreview the Output - table condensed (squished) to fit on the page (text wrapping within cells)\n\n\n\n\ngt_table\n\nPreview the Output\n\ntable condensed (squished) to fit on the page (text wrapping within cells)", +======= "text": "Testing what happens when the table is too wide (horizontal pagination)\n\nlibrary(gtsummary)\nlibrary(dplyr)\n\nset.seed(123)\ndata <- tibble(\n id = 1:100,\n age = sample(18:90, 100, replace = TRUE),\n sex = sample(c(\"Male\", \"Female\"), 100, replace = TRUE),\n race = sample(c(\"White\", \"Black\", \"Asian\", \"Hispanic\"), 100, replace = TRUE),\n bmi = round(runif(100, 18, 35), 1),\n smoking_status = sample(c(\"Never\", \"Former\", \"Current\"), 100, replace = TRUE),\n diabetes = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n hypertension = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n heart_disease = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cancer = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cholesterol = sample(c(\"Normal\", \"High\"), 100, replace = TRUE),\n exercise_frequency = sample(0:7, 100, replace = TRUE),\n alcohol_intake = sample(c(\"None\", \"Low\", \"Moderate\", \"High\"), 100, replace = TRUE),\n family_history = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n education = sample(c(\"High School\", \"College\", \"Graduate\", \"Post-Grad\", \"Middle School\", \"Elementary School\", \"Pre School\", \"Kindergarten\"), 100, replace = TRUE),\n marital_status = sample(c(\"Single\", \"Married\", \"Divorced\"), 100, replace = TRUE),\n employment_status = sample(c(\"Employed\", \"Unemployed\", \"Retired\"), 100, replace = TRUE),\n region = sample(c(\"North\", \"South\", \"East\", \"West\"), 100, replace = TRUE),\n health_insurance = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n medication = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n visits_last_year = sample(0:10, 100, replace = TRUE),\n satisfaction = sample(1:5, 100, replace = TRUE)\n)\n\n# Create a wide summary table\nsummary_table <- data %>%\n tbl_summary(\n by = education,\n statistic = list(all_continuous() ~ \"{mean} ({sd})\", \n all_categorical() ~ \"{n} ({p}%)\"),\n label = list(\n age ~ \"Age (years)\",\n bmi ~ \"BMI\",\n smoking_status ~ \"Smoking Status\",\n diabetes ~ \"Diabetes\",\n hypertension ~ \"Hypertension\",\n heart_disease ~ \"Heart Disease\",\n cancer ~ \"Cancer\",\n cholesterol ~ \"Cholesterol\",\n exercise_frequency ~ \"Exercise Frequency (days/week)\",\n alcohol_intake ~ \"Alcohol Intake\",\n family_history ~ \"Family History\",\n marital_status ~ \"Marital Status\",\n employment_status ~ \"Employment Status\",\n region ~ \"Region\",\n health_insurance ~ \"Health Insurance\",\n medication ~ \"On Medication\",\n visits_last_year ~ \"Visits Last Year\",\n satisfaction ~ \"Health Satisfaction (1-5)\"\n )\n ) %>%\n add_n() %>%\n modify_header(label = \"**Characteristic**\", estimate = \"**Mean (SD) or N (%)**\") %>%\n modify_table_styling(columns = everything()) %>%\n add_overall() # This adds an overall column\n\n\ngt_save PDF\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/pdf/too_wide_gt_pdf.pdf\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\ntable cut off at the end of the page (portrait)\n\n\n\n\n\n\nrmarkdown rendered PDF\n\nsummary_table\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\ntable cut off at the end of the page (portrait)\n\n\n\n\n\n\ngt_save rendered word file\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/docx/too_wide_gt_word.docx\")\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/too_wide_gt_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\ntable condensed (squished) to fit on the page (text wrapping within cells)\n\n\n\n\n\n\nquarto rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/too_wide_qmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\ntable condensed (squished) to fit on the page (text wrapping within cells)\n\n\n\n\n\n\nrmarkdown rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/too_wide_rmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\ntable condensed (squished) to fit on the page (text wrapping within cells)", +>>>>>>> main "crumbs": [ "Table Too Wide" ] @@ -24,7 +56,21 @@ "href": "08_text_styling.html", "title": "Text Styling", "section": "", +<<<<<<< HEAD + "text": "library(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n # Bold cells in table\n gt::tab_style(\n style = gt::cell_text(weight = \"bold\"), \n locations = gt::cells_body(columns = \"label\", rows = c(1, 3))\n ) \n\ngt_table\n\n\n\n\n\nThis is the caption [Used for cross referencing in Quarto]\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nage\ncontinuous\nlabel\nAge\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\nNA\nNA\nNA\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/bold_gt_pdf.pdf\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/bold_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", + "crumbs": [ + "Text Styling" + ] + }, + { + "objectID": "08_text_styling.html#testing-text-styling-output", + "href": "08_text_styling.html#testing-text-styling-output", + "title": "Text Styling", + "section": "", + "text": "library(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n # Bold cells in table\n gt::tab_style(\n style = gt::cell_text(weight = \"bold\"), \n locations = gt::cells_body(columns = \"label\", rows = c(1, 3))\n ) \n\ngt_table\n\n\n\n\n\nThis is the caption [Used for cross referencing in Quarto]\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nage\ncontinuous\nlabel\nAge\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\nNA\nNA\nNA\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/bold_gt_pdf.pdf\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/bold_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", +======= "text": "library(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n # Bold cells in table\n gt::tab_style(\n style = gt::cell_text(weight = \"bold\"), \n locations = gt::cells_body(columns = \"label\", rows = c(1, 3))\n ) \n\n\ngt_save PDF\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/bold_gt_pdf.pdf\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered PDF\n\ngt_table\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\ngt_save rendered word file\n\ngt::gtsave(gt_table, filename = \"outputs/docx/bold_gt_word.docx\")\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/bold_gt_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nquarto rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/text_style_qmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/text_style_rmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues", +>>>>>>> main "crumbs": [ "Text Styling" ] @@ -34,7 +80,21 @@ "href": "06_titles.html", "title": "Titles, Subtitles, and Captions", "section": "", +<<<<<<< HEAD + "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |> \n gt::sub_missing(missing_text = \"\") |> \n # title, subtitle, and captions\n gt::tab_header(gt::md(\"This is the Title\"), subtitle = \"This is the Subtitle\")\n\ngt_table\n\n\n\n\n\nThis is the caption\n\n\n\n\n\n\n\n\nThis is the Title\n\n\nThis is the Subtitle\n\n\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nUnknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/titles_gt_pdf.pdf\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/titles_gt_word.docx\")\n\nPreview the Output\n\nTitles present but right justified\nno caption\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nTitles present but right justified\nno caption\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nTitles present but right justified\nno caption", + "crumbs": [ + "Titles" + ] + }, + { + "objectID": "06_titles.html#testing-title-subtitle-and-caption-output", + "href": "06_titles.html#testing-title-subtitle-and-caption-output", + "title": "Titles", + "section": "", + "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |> \n gt::sub_missing(missing_text = \"\") |> \n # title, subtitle, and captions\n gt::tab_header(gt::md(\"This is the Title\"), subtitle = \"This is the Subtitle\")\n\ngt_table\n\n\n\n\n\nThis is the caption\n\n\n\n\n\n\n\n\nThis is the Title\n\n\nThis is the Subtitle\n\n\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nUnknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/titles_gt_pdf.pdf\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/titles_gt_word.docx\")\n\nPreview the Output\n\nTitles present but right justified\nno caption\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nTitles present but right justified\nno caption\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nTitles present but right justified\nno caption", +======= "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |> \n gt::sub_missing(missing_text = \"\") |> \n # title, subtitle, and captions\n gt::tab_header(gt::md(\"This is the Title\"), subtitle = \"This is the Subtitle\")\n\n\ngt_save PDF\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/titles_gt_pdf.pdf\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered PDF\n\ngt_table\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\ngt_save rendered word file\n\ngt::gtsave(gt_table, filename = \"outputs/docx/titles_gt_word.docx\")\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/titles_gt_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nTitles present but right justified\n\n\n2\n06/19/2025\nno caption\n\n\n\n\n\n\nquarto rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/titles_qmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nTitles present but right justified\n\n\n2\n06/19/2025\nno caption\n\n\n\n\n\n\nrmarkdown rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/titles_rmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nTitles present but right justified\n\n\n2\n06/19/2025\nno caption", +>>>>>>> main "crumbs": [ "Titles" ] @@ -44,12 +104,28 @@ "href": "04_footnotes.html", "title": "Footnotes", "section": "", +<<<<<<< HEAD + "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto; but I don't think a footnote can be attached]\")) |> \n gt::sub_missing(missing_text = \"\") |> \n gt::tab_spanner(gt::md(\"**Spanning Level 1**\"), columns = gtsummary::all_stat_cols(FALSE), level = 1L, id = \"stat_1_L1\") |>\n # footnotes\n gt::tab_footnote(\"Footnote in Header\", locations = gt::cells_column_labels(columns = label)) |> \n gt::tab_footnote(\"Footnote in Body\", locations = gt::cells_body(columns = label, row = 1L)) |> \n gt::tab_footnote(\"Footnote in Spanning Header\", locations = gt::cells_column_spanners(spanners = \"stat_1_L1\")) |> \n gt::tab_footnote(\"Footnote in Subtitle\", locations = gt::cells_title(\"subtitle\")) |> \n gt::tab_footnote(\"Footnote in Title\", locations = gt::cells_title(\"title\")) \n\ngt_table\n\n\n\n\n\nThis is the caption [Used for cross referencing in Quarto; but I don’t think a footnote can be attached]\n\n\n\n\n\n\n\n\n\n\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel2\nstat_0\n\nSpanning Level 11\n\n\n\nstat_1\nstat_2\n\n\n\n\nage\ncontinuous\nlabel\nAge\nAge3\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\n\n\n\n\n\n\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\n1 Footnote in Spanning Header\n\n\n2 Footnote in Header\n\n\n3 Footnote in Body\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/footnotes_gt_pdf.pdf\")\n\nPreview the Output\n-no issues\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/footnotes_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output - no issues\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", + "crumbs": [ + "Footnotes" + ] + }, + { + "objectID": "04_footnotes.html#testing-footnote-output", + "href": "04_footnotes.html#testing-footnote-output", + "title": "Footnotes", + "section": "", + "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto; but I don't think a footnote can be attached]\")) |> \n gt::sub_missing(missing_text = \"\") |> \n gt::tab_spanner(gt::md(\"**Spanning Level 1**\"), columns = gtsummary::all_stat_cols(FALSE), level = 1L, id = \"stat_1_L1\") |>\n # footnotes\n gt::tab_footnote(\"Footnote in Header\", locations = gt::cells_column_labels(columns = label)) |> \n gt::tab_footnote(\"Footnote in Body\", locations = gt::cells_body(columns = label, row = 1L)) |> \n gt::tab_footnote(\"Footnote in Spanning Header\", locations = gt::cells_column_spanners(spanners = \"stat_1_L1\")) |> \n gt::tab_footnote(\"Footnote in Subtitle\", locations = gt::cells_title(\"subtitle\")) |> \n gt::tab_footnote(\"Footnote in Title\", locations = gt::cells_title(\"title\")) \n\ngt_table\n\n\n\n\n\nThis is the caption [Used for cross referencing in Quarto; but I don’t think a footnote can be attached]\n\n\n\n\n\n\n\n\n\n\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel2\nstat_0\n\nSpanning Level 11\n\n\n\nstat_1\nstat_2\n\n\n\n\nage\ncontinuous\nlabel\nAge\nAge3\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\n\n\n\n\n\n\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\n1 Footnote in Spanning Header\n\n\n2 Footnote in Header\n\n\n3 Footnote in Body\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/footnotes_gt_pdf.pdf\")\n\nPreview the Output\n-no issues\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/footnotes_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output - no issues\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", +======= "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto; but I don't think a footnote can be attached]\")) |> \n gt::sub_missing(missing_text = \"\") |> \n gt::tab_spanner(gt::md(\"**Spanning Level 1**\"), columns = gtsummary::all_stat_cols(FALSE), level = 1L, id = \"stat_1_L1\") |>\n # footnotes\n gt::tab_footnote(\"Footnote in Header\", locations = gt::cells_column_labels(columns = label)) |> \n gt::tab_footnote(\"Footnote in Body\", locations = gt::cells_body(columns = label, row = 1L)) |> \n gt::tab_footnote(\"Footnote in Spanning Header\", locations = gt::cells_column_spanners(spanners = \"stat_1_L1\")) |> \n gt::tab_footnote(\"Footnote in Subtitle\", locations = gt::cells_title(\"subtitle\")) |> \n gt::tab_footnote(\"Footnote in Title\", locations = gt::cells_title(\"title\")) \n\n\ngt_save PDF\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/footnotes_gt_pdf.pdf\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered PDF\n\ngt_table\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\ngt_save rendered word file\n\ngt::gtsave(gt_table, filename = \"outputs/docx/footnotes_gt_word.docx\")\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/footnotes_gt_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nquarto rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/footnotes_qmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/footnotes_rmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues", +>>>>>>> main "crumbs": [ "Footnotes" ] }, { +<<<<<<< HEAD +======= "objectID": "02_indentation.html", "href": "02_indentation.html", "title": "Indentation", @@ -60,21 +136,80 @@ ] }, { +>>>>>>> main "objectID": "01_line_breaks.html", "href": "01_line_breaks.html", "title": "Line Breaks", "section": "", +<<<<<<< HEAD + "text": "Line breaks not being rendered correctly in a PDF is a known issue. We will skip the quarto rendered PDF and evaluate the line break behavior in other output options.\nThe example table evaluates line breaks in: - Title - Column Headers - Table Header - Cells\n\nlibrary(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age \\n\\U00A0\\U00A0linebreak in a cell\")) |> add_overall()\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n # Column headers with line breaks\n gt::cols_label(\n stat_0 = gt::md(\"**Overall**\"),\n stat_1 = gt::md(\"**Drug A** \\nManual Line Break\"), \n stat_2 = gt::md(\"**Drug B** \\nManual Line Break\")\n ) |> \n gt::tab_header(gt::md(\"This is the Title \\nwith a linebreak\"), subtitle = \"This is the Subtitle\")\n\ngt_table\n\n\n\n\n\nThis is the caption [Used for cross referencing in Quarto]\n\n\n\n\n\n\n\n\n\n\n\n\nThis is the Title with a linebreak\n\n\nThis is the Subtitle\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel\nOverall\nDrug A Manual Line Break\nDrug B Manual Line Break\n\n\n\n\nage\ncontinuous\nlabel\nAge   linebreak in a cell\nAge   linebreak in a cell\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge   linebreak in a cell\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\nNA\nNA\nNA\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/linebreaks_gt_pdf.pdf\")\n\nPreview the Output - manual linebreaks work - title linebreaks work - linebreak in a cell works\n\n\n\n\ngt_table\n\nPreview the Output\n\ntitle linebreaks work\nmanual linebreak works but disrupts cell alignment\nlinebreak in a cell doesn’t work\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/linebreaks_gt_word.docx\")\n\nPreview the Output - title linebreak not working - cell linebreak not working - manual linebreaks work\n\n\n\n\ngt_table\n\nPreview the Output\n\ntitle linebreak not working\ncell linebreak not working\nmanual linebreaks work\n\n\n\n\n\ngt_table\n\nPreview the Output\n\ntitle linebreak not working\ncell linebreak not working\nmanual linebreaks work", + "crumbs": [ + "Line Breaks" + ] + }, + { + "objectID": "01_line_breaks.html#testing-line-breaks-output", + "href": "01_line_breaks.html#testing-line-breaks-output", + "title": "Line Breaks", + "section": "", + "text": "Line breaks not being rendered correctly in a PDF is a known issue. We will skip the quarto rendered PDF and evaluate the line break behavior in other output options.\nThe example table evaluates line breaks in: - Title - Column Headers - Table Header - Cells\n\nlibrary(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age \\n\\U00A0\\U00A0linebreak in a cell\")) |> add_overall()\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n # Column headers with line breaks\n gt::cols_label(\n stat_0 = gt::md(\"**Overall**\"),\n stat_1 = gt::md(\"**Drug A** \\nManual Line Break\"), \n stat_2 = gt::md(\"**Drug B** \\nManual Line Break\")\n ) |> \n gt::tab_header(gt::md(\"This is the Title \\nwith a linebreak\"), subtitle = \"This is the Subtitle\")\n\ngt_table\n\n\n\n\n\nThis is the caption [Used for cross referencing in Quarto]\n\n\n\n\n\n\n\n\n\n\n\n\nThis is the Title with a linebreak\n\n\nThis is the Subtitle\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel\nOverall\nDrug A Manual Line Break\nDrug B Manual Line Break\n\n\n\n\nage\ncontinuous\nlabel\nAge   linebreak in a cell\nAge   linebreak in a cell\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge   linebreak in a cell\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\nNA\nNA\nNA\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/linebreaks_gt_pdf.pdf\")\n\nPreview the Output - manual linebreaks work - title linebreaks work - linebreak in a cell works\n\n\n\n\ngt_table\n\nPreview the Output\n\ntitle linebreaks work\nmanual linebreak works but disrupts cell alignment\nlinebreak in a cell doesn’t work\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/linebreaks_gt_word.docx\")\n\nPreview the Output - title linebreak not working - cell linebreak not working - manual linebreaks work\n\n\n\n\ngt_table\n\nPreview the Output\n\ntitle linebreak not working\ncell linebreak not working\nmanual linebreaks work\n\n\n\n\n\ngt_table\n\nPreview the Output\n\ntitle linebreak not working\ncell linebreak not working\nmanual linebreaks work", +======= "text": "Line breaks not being rendered correctly in a PDF is a known issue. We will skip the quarto rendered PDF and evaluate the line break behavior in other output options.\nThe example table evaluates line breaks in:\n\nTitle\nColumn Headers\nTable Headers\nCells\n\n\nlibrary(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age \\n\\U00A0\\U00A0linebreak in a cell\")) |> add_overall()\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n # Column headers with line breaks\n gt::cols_label(\n stat_0 = gt::md(\"**Overall**\"),\n stat_1 = gt::md(\"**Drug A** \\nManual Line Break\"), \n stat_2 = gt::md(\"**Drug B** \\nManual Line Break\")\n ) |> \n gt::tab_header(gt::md(\"This is the Title \\nwith a linebreak\"), subtitle = \"This is the Subtitle\")\n\n\ngt_save PDF\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/linebreaks_gt_pdf2.pdf\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nmanual linebreaks work\n\n\n2\n06/19/2025\ntitle linebreaks work\n\n\n3\n06/19/2025\nlinebreaks in a cell works\n\n\n\n\n\n\nrmarkdown rendered PDF\n\ngt_table\n\n\nPreview the Output\n\n\n\n\n\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\ntitle linebreaks work\n\n\n2\n06/19/2025\nmanual linebreak works but disrupts cell alignment\n\n\n3\n06/19/2025\nlinebreak in a cell doesn’t work\n\n\n\n\n\n\ngt_save rendered word file\n\ngt::gtsave(gt_table, filename = \"outputs/docx/linebreaks_gt_word.docx\")\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/linebreaks_gt_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\ntitle linebreak not working\n\n\n2\n06/19/2025\ncell linebreak not working\n\n\n3\n06/19/2025\nmanual linebreaks work\n\n\n\n\n\n\nquarto rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/linebreaks_qmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\ntitle linebreak not working\n\n\n2\n06/19/2025\ncell linebreak not working\n\n\n3\n06/19/2025\nmanual linebreaks work\n\n\n\n\n\n\nrmarkdown rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/linebreaks_rmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\ntitle linebreak not working\n\n\n2\n06/19/2025\ncell linebreak not working\n\n\n3\n06/19/2025\nmanual linebreaks work", +>>>>>>> main "crumbs": [ "Line Breaks" ] }, + { + "objectID": "12_other_engines.html", + "href": "12_other_engines.html", + "title": "Output Engines Experimentation", + "section": "", + "text": "Other table output options were experimented with but did not carry forward as the outputs did not render correctly. Below are the results of a few engines tried.", + "crumbs": [ + "Other Engines" + ] + }, + { + "objectID": "12_other_engines.html#typst-pdf", + "href": "12_other_engines.html#typst-pdf", + "title": "Output Engines Experimentation", + "section": "Typst PDF", + "text": "Typst PDF\n\nlibrary(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age \\n\\U00A0\\U00A0linebreak in a cell\")) |> add_overall()\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n # Column headers with line breaks\n gt::cols_label(\n stat_0 = gt::md(\"**Overall**\"),\n stat_1 = gt::md(\"**Drug A** \\nManual Line Break\"), \n stat_2 = gt::md(\"**Drug B** \\nManual Line Break\")\n ) |> \n gt::tab_header(gt::md(\"This is the Title \\nwith a linebreak\"), subtitle = \"This is the Subtitle\")\n\ngt_table\n\nPreview the Output\n{{< pdf outputs/quarto_typst.pdf 100% 800 >}}", + "crumbs": [ + "Other Engines" + ] + }, + { + "objectID": "index.html", + "href": "index.html", + "title": "Table Drawing Research", + "section": "", + "text": "Overview\nTables built in {gtsummary} typically use {gt} functions to draw and render tables in different output formats. As a result, not all table customization translated correctly. This repo is used to experiment and identify potential adaptions to {gt} functions to maintain as much of the table decoration as possible when exporting to other formats. Currently exploring: HTML, PDF (with and without Typst), and Word (.docx) outputs.\nBelow is the sample {gtsummary} table with notable customizations (footnotes, headers, titles, linebreaks, indentations, etc.) we are tracking.\n\n\n\n\n\n This is the caption\n[Used for cross referencing in Quarto]\n \n \n This is the Title\nwith a linebreak1\n \n \n This is the Subtitle2\n \n \n \n \n Spanning Level 2\n \n \n \n Characteristic\n    Indented Header4\n \n Both Treatments\n \n \n Spanning Level 13\n \n \n \n Overall\n Drug A\nManual Line Break\n Drug B\nManual Line Break\n \n \n \n Age\n  linebreak in a cell5\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n       Unknown\n11\n7\n4\n Grade\n\n\n\n   I\n68 (34%)\n35 (36%)\n33 (32%)\n   II\n68 (34%)\n32 (33%)\n36 (35%)\n   III\n64 (32%)\n31 (32%)\n33 (32%)\n       Unknown\n0\n0\n0\n \n \n \n This is Source Note 1\n \n \n This is Source Note 2\n \n \n Abbreviations: Q1 = First Quartile; Q3 = Third Quartile\n \n \n \n \n 1 Footnote in Title\n \n \n 2 Footnote in Subtitle\n \n \n 3 Footnote in Spanning Header\n \n \n 4 Footnote in Header\n \n \n 5 Footnote in Body\n \n \n\n\n\n\n\nIssue Log\nHere we document things that were discovered through this output analysis with date stamps that can be updated as feature requests are addressed.\n2025-03-03 - No caption in all .docx exports - Titles in .docx output (using gtsave) are left-justified (not centered with the table) - Linebreaks aren’t applied to “header” content in .docx output - “Table 1” text is automatically added when not supplied a title (.docx)", + "crumbs": [ + "Home" + ] + }, { "objectID": "03_spanning_header.html", "href": "03_spanning_header.html", "title": "Spanning Header", "section": "", +<<<<<<< HEAD + "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |> \n gt::sub_missing(missing_text = \"\") |> \n # spanning headers 1 and 2 levels\n gt::tab_spanner(gt::md(\"**Spanning Level 2**\"), columns = gtsummary::all_stat_cols(), level = 2L, id = \"stat_1_L2\") |> \n gt::tab_spanner(gt::md(\"**Spanning Level 1**\"), columns = gtsummary::all_stat_cols(FALSE), level = 1L, id = \"stat_1_L1\") |> \n gt::tab_spanner(gt::md(\"**Both Treatments**\"), columns = stat_0, level = 1L, id = \"stat_0_L1\") \n\ngt_table\n\n\n\n\n\nThis is the caption\n\n\n\n\n\n\n\n\n\n\nSpanning Level 2\n\n\n\nlabel\n\nBoth Treatments\n\n\nSpanning Level 1\n\n\n\nstat_0\nstat_1\nstat_2\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nUnknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/spanning_header_gt_pdf.pdf\")\n\nPreview the Output - no issues\n\n\n\n\ngt_table\n\nPreview the Output - no issues\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/spanning_header_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", + "crumbs": [ + "Spanning Header" + ] + }, + { + "objectID": "03_spanning_header.html#testing-spanning-header-output", + "href": "03_spanning_header.html#testing-spanning-header-output", + "title": "Spanning Header", + "section": "", + "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |> \n gt::sub_missing(missing_text = \"\") |> \n # spanning headers 1 and 2 levels\n gt::tab_spanner(gt::md(\"**Spanning Level 2**\"), columns = gtsummary::all_stat_cols(), level = 2L, id = \"stat_1_L2\") |> \n gt::tab_spanner(gt::md(\"**Spanning Level 1**\"), columns = gtsummary::all_stat_cols(FALSE), level = 1L, id = \"stat_1_L1\") |> \n gt::tab_spanner(gt::md(\"**Both Treatments**\"), columns = stat_0, level = 1L, id = \"stat_0_L1\") \n\ngt_table\n\n\n\n\n\nThis is the caption\n\n\n\n\n\n\n\n\n\n\nSpanning Level 2\n\n\n\nlabel\n\nBoth Treatments\n\n\nSpanning Level 1\n\n\n\nstat_0\nstat_1\nstat_2\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nUnknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/spanning_header_gt_pdf.pdf\")\n\nPreview the Output - no issues\n\n\n\n\ngt_table\n\nPreview the Output - no issues\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/spanning_header_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", +======= "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |> \n gt::sub_missing(missing_text = \"\") |> \n # spanning headers 1 and 2 levels\n gt::tab_spanner(gt::md(\"**Spanning Level 2**\"), columns = gtsummary::all_stat_cols(), level = 2L, id = \"stat_1_L2\") |> \n gt::tab_spanner(gt::md(\"**Spanning Level 1**\"), columns = gtsummary::all_stat_cols(FALSE), level = 1L, id = \"stat_1_L1\") |> \n gt::tab_spanner(gt::md(\"**Both Treatments**\"), columns = stat_0, level = 1L, id = \"stat_0_L1\") \n\n\ngt_save PDF\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/spanning_header_gt_pdf.pdf\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered PDF\n\ngt_table\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\ngt_save rendered word file\n\ngt::gtsave(gt_table, filename = \"outputs/docx/spanning_header_gt_word.docx\")\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/spanning_header_gt_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nquarto rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/spanning_header_qmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/spanning_header_rmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues", +>>>>>>> main "crumbs": [ "Spanning Header" ] @@ -84,7 +219,21 @@ "href": "05_source_notes.html", "title": "Source Notes", "section": "", +<<<<<<< HEAD + "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n #source notes\n gt::tab_source_note(\"This is Source Note 1\") |> \n gt::tab_source_note(\"This is Source Note 2\") |> \n gt::tab_source_note(\"Abbreviations: Q1 = First Quartile; Q3 = Third Quartile\")\n\ngt_table\n\n\n\n\n\nThis is the caption\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nage\ncontinuous\nlabel\nAge\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\nNA\nNA\nNA\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\nThis is Source Note 1\n\n\nThis is Source Note 2\n\n\nAbbreviations: Q1 = First Quartile; Q3 = Third Quartile\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/source_notes_gt_pdf.pdf\")\n\nPreview the Output -no issues\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/source_notes_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", + "crumbs": [ + "Source Notes" + ] + }, + { + "objectID": "05_source_notes.html#testing-source-note-output", + "href": "05_source_notes.html#testing-source-note-output", + "title": "Source Notes", + "section": "", + "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n #source notes\n gt::tab_source_note(\"This is Source Note 1\") |> \n gt::tab_source_note(\"This is Source Note 2\") |> \n gt::tab_source_note(\"Abbreviations: Q1 = First Quartile; Q3 = Third Quartile\")\n\ngt_table\n\n\n\n\n\nThis is the caption\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nage\ncontinuous\nlabel\nAge\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\nNA\nNA\nNA\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\nThis is Source Note 1\n\n\nThis is Source Note 2\n\n\nAbbreviations: Q1 = First Quartile; Q3 = Third Quartile\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/source_notes_gt_pdf.pdf\")\n\nPreview the Output -no issues\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/source_notes_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", +======= "text": "library(gtsummary)\n\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n #source notes\n gt::tab_source_note(\"This is Source Note 1\") |> \n gt::tab_source_note(\"This is Source Note 2\") |> \n gt::tab_source_note(\"Abbreviations: Q1 = First Quartile; Q3 = Third Quartile\")\n\n\ngt_save PDF\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/source_notes_gt_pdf.pdf\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered PDF\n\ngt_table\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\ngt_save rendered word file\n\ngt::gtsave(gt_table, filename = \"outputs/docx/source_notes_gt_word.docx\")\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/source_notes_gt_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nquarto rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/source_notes_qmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/source_notes_rmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues", +>>>>>>> main "crumbs": [ "Source Notes" ] @@ -94,7 +243,21 @@ "href": "07_alignment.html", "title": "Alignment", "section": "", +<<<<<<< HEAD + "text": "library(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n gt::cols_align(columns = c(stat_1, stat_2), align = \"right\") |> \n gt::cols_align(columns = c(variable, var_type), align = \"center\") |>\n gt::cols_align(columns = c(row_type, var_label), align = \"left\")\n\ngt_table\n\n\n\n\n\nThis is the caption [Used for cross referencing in Quarto]\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nage\ncontinuous\nlabel\nAge\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\nNA\nNA\nNA\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/alignment_gt_pdf.pdf\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/alignment_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", + "crumbs": [ + "Alignment" + ] + }, + { + "objectID": "07_alignment.html#testing-alignments-output", + "href": "07_alignment.html#testing-alignments-output", + "title": "Alignment", + "section": "", + "text": "library(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n gt::cols_align(columns = c(stat_1, stat_2), align = \"right\") |> \n gt::cols_align(columns = c(variable, var_type), align = \"center\") |>\n gt::cols_align(columns = c(row_type, var_label), align = \"left\")\n\ngt_table\n\n\n\n\n\nThis is the caption [Used for cross referencing in Quarto]\n\n\nvariable\nvar_type\nrow_type\nvar_label\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nage\ncontinuous\nlabel\nAge\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\nage\ncontinuous\nmissing\nAge\nUnknown\n11\n7\n4\n\n\ngrade\ncategorical\nlabel\nGrade\nGrade\nNA\nNA\nNA\n\n\ngrade\ncategorical\nlevel\nGrade\nI\n68 (34%)\n35 (36%)\n33 (32%)\n\n\ngrade\ncategorical\nlevel\nGrade\nII\n68 (34%)\n32 (33%)\n36 (35%)\n\n\ngrade\ncategorical\nlevel\nGrade\nIII\n64 (32%)\n31 (32%)\n33 (32%)\n\n\ngrade\ncategorical\nmissing\nGrade\nUnknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/alignment_gt_pdf.pdf\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/alignment_gt_word.docx\")\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nno issues", +======= "text": "library(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n gt::cols_align(columns = c(stat_1, stat_2), align = \"right\") |> \n gt::cols_align(columns = c(variable, var_type), align = \"center\") |>\n gt::cols_align(columns = c(row_type, var_label), align = \"left\")\n\n\ngt_save PDF\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/alignment_gt_pdf.pdf\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered PDF\n\ngt_table\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\ngt_save rendered word file\n\ngt::gtsave(gt_table, filename = \"outputs/docx/alignment_gt_word.docx\")\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/alignment_gt_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nquarto rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/alignment_qmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues\n\n\n\n\n\n\nrmarkdown rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/alignment_rmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nno issues", +>>>>>>> main "crumbs": [ "Alignment" ] @@ -104,29 +267,51 @@ "href": "09_tbl_too_long.html", "title": "Table Too Long", "section": "", +<<<<<<< HEAD + "text": "library(gtsummary)\nlibrary(dplyr)\n\n\nAttaching package: 'dplyr'\n\n\nThe following objects are masked from 'package:stats':\n\n filter, lag\n\n\nThe following objects are masked from 'package:base':\n\n intersect, setdiff, setequal, union\n\nset.seed(123)\ndata <- dplyr::tibble(\n id = 1:100,\n age = sample(18:90, 100, replace = TRUE),\n sex = sample(c(\"Male\", \"Female\"), 100, replace = TRUE),\n race = sample(c(\"White\", \"Black\", \"Asian\", \"Hispanic\"), 100, replace = TRUE),\n bmi = round(runif(100, 18, 35), 1),\n smoking_status = sample(c(\"Never\", \"Former\", \"Current\"), 100, replace = TRUE),\n diabetes = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n hypertension = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n heart_disease = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cancer = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cholesterol = sample(c(\"Normal\", \"High\"), 100, replace = TRUE),\n exercise_frequency = sample(0:7, 100, replace = TRUE),\n alcohol_intake = sample(c(\"None\", \"Low\", \"Moderate\", \"High\"), 100, replace = TRUE),\n family_history = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n education = sample(c(\"High School\", \"College\", \"Graduate\"), 100, replace = TRUE),\n marital_status = sample(c(\"Single\", \"Married\", \"Divorced\"), 100, replace = TRUE),\n employment_status = sample(c(\"Employed\", \"Unemployed\", \"Retired\"), 100, replace = TRUE),\n region = sample(c(\"North\", \"South\", \"East\", \"West\"), 100, replace = TRUE),\n health_insurance = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n medication = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n visits_last_year = sample(0:10, 100, replace = TRUE),\n satisfaction = sample(1:5, 100, replace = TRUE)\n)\n\n# Create summary table\nsummary_table <- data %>%\n tbl_summary(\n by = sex, # Group by sex\n statistic = list(all_continuous() ~ \"{mean} ({sd})\", all_categorical() ~ \"{n} ({p}%)\"),\n label = list(\n age ~ \"Age (years)\",\n bmi ~ \"BMI\",\n smoking_status ~ \"Smoking Status\",\n diabetes ~ \"Diabetes\",\n hypertension ~ \"Hypertension\",\n heart_disease ~ \"Heart Disease\",\n cancer ~ \"Cancer\",\n cholesterol ~ \"Cholesterol\",\n exercise_frequency ~ \"Exercise Frequency (days/week)\",\n alcohol_intake ~ \"Alcohol Intake\",\n family_history ~ \"Family History\",\n education ~ \"Education Level\",\n marital_status ~ \"Marital Status\",\n employment_status ~ \"Employment Status\",\n region ~ \"Region\",\n health_insurance ~ \"Health Insurance\",\n medication ~ \"On Medication\",\n visits_last_year ~ \"Visits Last Year\",\n satisfaction ~ \"Health Satisfaction (1-5)\"\n )\n ) %>%\n add_n() %>%\n modify_header(label = \"**Characteristic**\", estimate = \"**Mean (SD) or N (%)**\") %>%\n modify_table_styling(columns = everything())\n\nsummary_table\n\n\n\n\n\n\n\n\n\n\n\n\n\nCharacteristic\nN\nFemale N = 501\nMale N = 501\n\n\n\n\nid\n100\n46 (29)\n55 (29)\n\n\nAge (years)\n100\n54 (21)\n52 (19)\n\n\nrace\n100\n\n\n\n\n\n\n    Asian\n\n\n9 (18%)\n7 (14%)\n\n\n    Black\n\n\n13 (26%)\n14 (28%)\n\n\n    Hispanic\n\n\n9 (18%)\n8 (16%)\n\n\n    White\n\n\n19 (38%)\n21 (42%)\n\n\nBMI\n100\n25.9 (4.7)\n26.4 (5.1)\n\n\nSmoking Status\n100\n\n\n\n\n\n\n    Current\n\n\n23 (46%)\n16 (32%)\n\n\n    Former\n\n\n15 (30%)\n22 (44%)\n\n\n    Never\n\n\n12 (24%)\n12 (24%)\n\n\nDiabetes\n100\n26 (52%)\n23 (46%)\n\n\nHypertension\n100\n29 (58%)\n24 (48%)\n\n\nHeart Disease\n100\n20 (40%)\n31 (62%)\n\n\nCancer\n100\n32 (64%)\n18 (36%)\n\n\nCholesterol\n100\n\n\n\n\n\n\n    High\n\n\n21 (42%)\n26 (52%)\n\n\n    Normal\n\n\n29 (58%)\n24 (48%)\n\n\nExercise Frequency (days/week)\n100\n\n\n\n\n\n\n    0\n\n\n9 (18%)\n4 (8.0%)\n\n\n    1\n\n\n5 (10%)\n3 (6.0%)\n\n\n    2\n\n\n5 (10%)\n5 (10%)\n\n\n    3\n\n\n6 (12%)\n7 (14%)\n\n\n    4\n\n\n7 (14%)\n8 (16%)\n\n\n    5\n\n\n3 (6.0%)\n9 (18%)\n\n\n    6\n\n\n5 (10%)\n5 (10%)\n\n\n    7\n\n\n10 (20%)\n9 (18%)\n\n\nAlcohol Intake\n100\n\n\n\n\n\n\n    High\n\n\n12 (24%)\n9 (18%)\n\n\n    Low\n\n\n12 (24%)\n17 (34%)\n\n\n    Moderate\n\n\n11 (22%)\n14 (28%)\n\n\n    None\n\n\n15 (30%)\n10 (20%)\n\n\nFamily History\n100\n34 (68%)\n23 (46%)\n\n\nEducation Level\n100\n\n\n\n\n\n\n    College\n\n\n17 (34%)\n18 (36%)\n\n\n    Graduate\n\n\n13 (26%)\n17 (34%)\n\n\n    High School\n\n\n20 (40%)\n15 (30%)\n\n\nMarital Status\n100\n\n\n\n\n\n\n    Divorced\n\n\n17 (34%)\n21 (42%)\n\n\n    Married\n\n\n14 (28%)\n16 (32%)\n\n\n    Single\n\n\n19 (38%)\n13 (26%)\n\n\nEmployment Status\n100\n\n\n\n\n\n\n    Employed\n\n\n16 (32%)\n18 (36%)\n\n\n    Retired\n\n\n19 (38%)\n14 (28%)\n\n\n    Unemployed\n\n\n15 (30%)\n18 (36%)\n\n\nRegion\n100\n\n\n\n\n\n\n    East\n\n\n11 (22%)\n9 (18%)\n\n\n    North\n\n\n12 (24%)\n22 (44%)\n\n\n    South\n\n\n12 (24%)\n12 (24%)\n\n\n    West\n\n\n15 (30%)\n7 (14%)\n\n\nHealth Insurance\n100\n26 (52%)\n25 (50%)\n\n\nOn Medication\n100\n27 (54%)\n24 (48%)\n\n\nVisits Last Year\n100\n5 (3)\n5 (3)\n\n\nHealth Satisfaction (1-5)\n100\n\n\n\n\n\n\n    1\n\n\n11 (22%)\n18 (36%)\n\n\n    2\n\n\n13 (26%)\n8 (16%)\n\n\n    3\n\n\n11 (22%)\n8 (16%)\n\n\n    4\n\n\n10 (20%)\n9 (18%)\n\n\n    5\n\n\n5 (10%)\n7 (14%)\n\n\n\n1 Mean (SD); n (%)\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/pdf/too_long_gt_pdf.pdf\")\n\nPreview the Output\n\nprinted on multiple pages\nheader and footnotes repeated on each page\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nprinted on one page\ntable cut off at the end of the page\n\n\n\n\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/docx/too_long_gt_word.docx\")\n\nPreview the Output\n\nprinted on multiple pages (continued)\nheader repeated on each page\nfooter only on the last page\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nprinted on multiple pages (continued)\nheader repeated on each page\nfooter only on the last page\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nprinted on multiple pages (continued)\nheader repeated on each page\nfooter only on the last page", + "crumbs": [ + "Table Too Long" + ] + }, + { + "objectID": "09_tbl_too_long.html#testing-output-when-the-table-is-too-long", + "href": "09_tbl_too_long.html#testing-output-when-the-table-is-too-long", + "title": "Table Too Long", + "section": "", + "text": "library(gtsummary)\nlibrary(dplyr)\n\n\nAttaching package: 'dplyr'\n\n\nThe following objects are masked from 'package:stats':\n\n filter, lag\n\n\nThe following objects are masked from 'package:base':\n\n intersect, setdiff, setequal, union\n\nset.seed(123)\ndata <- dplyr::tibble(\n id = 1:100,\n age = sample(18:90, 100, replace = TRUE),\n sex = sample(c(\"Male\", \"Female\"), 100, replace = TRUE),\n race = sample(c(\"White\", \"Black\", \"Asian\", \"Hispanic\"), 100, replace = TRUE),\n bmi = round(runif(100, 18, 35), 1),\n smoking_status = sample(c(\"Never\", \"Former\", \"Current\"), 100, replace = TRUE),\n diabetes = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n hypertension = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n heart_disease = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cancer = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cholesterol = sample(c(\"Normal\", \"High\"), 100, replace = TRUE),\n exercise_frequency = sample(0:7, 100, replace = TRUE),\n alcohol_intake = sample(c(\"None\", \"Low\", \"Moderate\", \"High\"), 100, replace = TRUE),\n family_history = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n education = sample(c(\"High School\", \"College\", \"Graduate\"), 100, replace = TRUE),\n marital_status = sample(c(\"Single\", \"Married\", \"Divorced\"), 100, replace = TRUE),\n employment_status = sample(c(\"Employed\", \"Unemployed\", \"Retired\"), 100, replace = TRUE),\n region = sample(c(\"North\", \"South\", \"East\", \"West\"), 100, replace = TRUE),\n health_insurance = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n medication = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n visits_last_year = sample(0:10, 100, replace = TRUE),\n satisfaction = sample(1:5, 100, replace = TRUE)\n)\n\n# Create summary table\nsummary_table <- data %>%\n tbl_summary(\n by = sex, # Group by sex\n statistic = list(all_continuous() ~ \"{mean} ({sd})\", all_categorical() ~ \"{n} ({p}%)\"),\n label = list(\n age ~ \"Age (years)\",\n bmi ~ \"BMI\",\n smoking_status ~ \"Smoking Status\",\n diabetes ~ \"Diabetes\",\n hypertension ~ \"Hypertension\",\n heart_disease ~ \"Heart Disease\",\n cancer ~ \"Cancer\",\n cholesterol ~ \"Cholesterol\",\n exercise_frequency ~ \"Exercise Frequency (days/week)\",\n alcohol_intake ~ \"Alcohol Intake\",\n family_history ~ \"Family History\",\n education ~ \"Education Level\",\n marital_status ~ \"Marital Status\",\n employment_status ~ \"Employment Status\",\n region ~ \"Region\",\n health_insurance ~ \"Health Insurance\",\n medication ~ \"On Medication\",\n visits_last_year ~ \"Visits Last Year\",\n satisfaction ~ \"Health Satisfaction (1-5)\"\n )\n ) %>%\n add_n() %>%\n modify_header(label = \"**Characteristic**\", estimate = \"**Mean (SD) or N (%)**\") %>%\n modify_table_styling(columns = everything())\n\nsummary_table\n\n\n\n\n\n\n\n\n\n\n\n\n\nCharacteristic\nN\nFemale N = 501\nMale N = 501\n\n\n\n\nid\n100\n46 (29)\n55 (29)\n\n\nAge (years)\n100\n54 (21)\n52 (19)\n\n\nrace\n100\n\n\n\n\n\n\n    Asian\n\n\n9 (18%)\n7 (14%)\n\n\n    Black\n\n\n13 (26%)\n14 (28%)\n\n\n    Hispanic\n\n\n9 (18%)\n8 (16%)\n\n\n    White\n\n\n19 (38%)\n21 (42%)\n\n\nBMI\n100\n25.9 (4.7)\n26.4 (5.1)\n\n\nSmoking Status\n100\n\n\n\n\n\n\n    Current\n\n\n23 (46%)\n16 (32%)\n\n\n    Former\n\n\n15 (30%)\n22 (44%)\n\n\n    Never\n\n\n12 (24%)\n12 (24%)\n\n\nDiabetes\n100\n26 (52%)\n23 (46%)\n\n\nHypertension\n100\n29 (58%)\n24 (48%)\n\n\nHeart Disease\n100\n20 (40%)\n31 (62%)\n\n\nCancer\n100\n32 (64%)\n18 (36%)\n\n\nCholesterol\n100\n\n\n\n\n\n\n    High\n\n\n21 (42%)\n26 (52%)\n\n\n    Normal\n\n\n29 (58%)\n24 (48%)\n\n\nExercise Frequency (days/week)\n100\n\n\n\n\n\n\n    0\n\n\n9 (18%)\n4 (8.0%)\n\n\n    1\n\n\n5 (10%)\n3 (6.0%)\n\n\n    2\n\n\n5 (10%)\n5 (10%)\n\n\n    3\n\n\n6 (12%)\n7 (14%)\n\n\n    4\n\n\n7 (14%)\n8 (16%)\n\n\n    5\n\n\n3 (6.0%)\n9 (18%)\n\n\n    6\n\n\n5 (10%)\n5 (10%)\n\n\n    7\n\n\n10 (20%)\n9 (18%)\n\n\nAlcohol Intake\n100\n\n\n\n\n\n\n    High\n\n\n12 (24%)\n9 (18%)\n\n\n    Low\n\n\n12 (24%)\n17 (34%)\n\n\n    Moderate\n\n\n11 (22%)\n14 (28%)\n\n\n    None\n\n\n15 (30%)\n10 (20%)\n\n\nFamily History\n100\n34 (68%)\n23 (46%)\n\n\nEducation Level\n100\n\n\n\n\n\n\n    College\n\n\n17 (34%)\n18 (36%)\n\n\n    Graduate\n\n\n13 (26%)\n17 (34%)\n\n\n    High School\n\n\n20 (40%)\n15 (30%)\n\n\nMarital Status\n100\n\n\n\n\n\n\n    Divorced\n\n\n17 (34%)\n21 (42%)\n\n\n    Married\n\n\n14 (28%)\n16 (32%)\n\n\n    Single\n\n\n19 (38%)\n13 (26%)\n\n\nEmployment Status\n100\n\n\n\n\n\n\n    Employed\n\n\n16 (32%)\n18 (36%)\n\n\n    Retired\n\n\n19 (38%)\n14 (28%)\n\n\n    Unemployed\n\n\n15 (30%)\n18 (36%)\n\n\nRegion\n100\n\n\n\n\n\n\n    East\n\n\n11 (22%)\n9 (18%)\n\n\n    North\n\n\n12 (24%)\n22 (44%)\n\n\n    South\n\n\n12 (24%)\n12 (24%)\n\n\n    West\n\n\n15 (30%)\n7 (14%)\n\n\nHealth Insurance\n100\n26 (52%)\n25 (50%)\n\n\nOn Medication\n100\n27 (54%)\n24 (48%)\n\n\nVisits Last Year\n100\n5 (3)\n5 (3)\n\n\nHealth Satisfaction (1-5)\n100\n\n\n\n\n\n\n    1\n\n\n11 (22%)\n18 (36%)\n\n\n    2\n\n\n13 (26%)\n8 (16%)\n\n\n    3\n\n\n11 (22%)\n8 (16%)\n\n\n    4\n\n\n10 (20%)\n9 (18%)\n\n\n    5\n\n\n5 (10%)\n7 (14%)\n\n\n\n1 Mean (SD); n (%)\n\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/pdf/too_long_gt_pdf.pdf\")\n\nPreview the Output\n\nprinted on multiple pages\nheader and footnotes repeated on each page\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nprinted on one page\ntable cut off at the end of the page\n\n\n\n\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/docx/too_long_gt_word.docx\")\n\nPreview the Output\n\nprinted on multiple pages (continued)\nheader repeated on each page\nfooter only on the last page\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nprinted on multiple pages (continued)\nheader repeated on each page\nfooter only on the last page\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nprinted on multiple pages (continued)\nheader repeated on each page\nfooter only on the last page", +======= "text": "Testing when the table is too long to fit on the page (vertical pagination).\n\nlibrary(gtsummary)\nlibrary(dplyr)\n\nset.seed(123)\ndata <- dplyr::tibble(\n id = 1:100,\n age = sample(18:90, 100, replace = TRUE),\n sex = sample(c(\"Male\", \"Female\"), 100, replace = TRUE),\n race = sample(c(\"White\", \"Black\", \"Asian\", \"Hispanic\"), 100, replace = TRUE),\n bmi = round(runif(100, 18, 35), 1),\n smoking_status = sample(c(\"Never\", \"Former\", \"Current\"), 100, replace = TRUE),\n diabetes = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n hypertension = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n heart_disease = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cancer = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n cholesterol = sample(c(\"Normal\", \"High\"), 100, replace = TRUE),\n exercise_frequency = sample(0:7, 100, replace = TRUE),\n alcohol_intake = sample(c(\"None\", \"Low\", \"Moderate\", \"High\"), 100, replace = TRUE),\n family_history = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n education = sample(c(\"High School\", \"College\", \"Graduate\"), 100, replace = TRUE),\n marital_status = sample(c(\"Single\", \"Married\", \"Divorced\"), 100, replace = TRUE),\n employment_status = sample(c(\"Employed\", \"Unemployed\", \"Retired\"), 100, replace = TRUE),\n region = sample(c(\"North\", \"South\", \"East\", \"West\"), 100, replace = TRUE),\n health_insurance = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n medication = sample(c(\"Yes\", \"No\"), 100, replace = TRUE),\n visits_last_year = sample(0:10, 100, replace = TRUE),\n satisfaction = sample(1:5, 100, replace = TRUE)\n)\n\n# Create summary table\nsummary_table <- data %>%\n tbl_summary(\n by = sex, # Group by sex\n statistic = list(all_continuous() ~ \"{mean} ({sd})\", all_categorical() ~ \"{n} ({p}%)\"),\n label = list(\n age ~ \"Age (years)\",\n bmi ~ \"BMI\",\n smoking_status ~ \"Smoking Status\",\n diabetes ~ \"Diabetes\",\n hypertension ~ \"Hypertension\",\n heart_disease ~ \"Heart Disease\",\n cancer ~ \"Cancer\",\n cholesterol ~ \"Cholesterol\",\n exercise_frequency ~ \"Exercise Frequency (days/week)\",\n alcohol_intake ~ \"Alcohol Intake\",\n family_history ~ \"Family History\",\n education ~ \"Education Level\",\n marital_status ~ \"Marital Status\",\n employment_status ~ \"Employment Status\",\n region ~ \"Region\",\n health_insurance ~ \"Health Insurance\",\n medication ~ \"On Medication\",\n visits_last_year ~ \"Visits Last Year\",\n satisfaction ~ \"Health Satisfaction (1-5)\"\n )\n ) %>%\n add_n() %>%\n modify_header(label = \"**Characteristic**\", estimate = \"**Mean (SD) or N (%)**\") %>%\n modify_table_styling(columns = everything())\n\n\ngt_save PDF\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/pdf/too_long_gt_pdf.pdf\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nprinted on multiple pages\n\n\n2\n06/19/2025\nheader and footnotes repeated on each page\n\n\n\n\n\n\nrmarkdown rendered PDF\n\ngt_table\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nprinted on one page\n\n\n2\n06/19/2025\ntable cut off at the end of the page\n\n\n\n\n\n\ngt_save rendered word file\n\ngt::gtsave(as_gt(summary_table), filename = \"outputs/docx/too_long_gt_word.docx\")\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/too_long_gt_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nprinted on multiple pages (continued)\n\n\n2\n06/19/2025\nheader repeated on each page\n\n\n3\n01/19/2025\nfooter only on the last page\n\n\n\n\n\n\nquarto rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/too_long_qmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nprinted on multiple pages (continued)\n\n\n2\n06/19/2025\nheader repeated on each page\n\n\n3\n01/19/2025\nfooter only on the last page\n\n\n\n\n\n\nrmarkdown rendered word file\n\ngt_table\n# converting word to pdf locally \ndoconv::docx2pdf(\"outputs/docx/too_long_rmd_word.docx\")\n\n\nPreview the Output\n\n\n\n\n\nDate\nFinding\n\n\n\n\n1\n06/19/2025\nprinted on multiple pages (continued)\n\n\n2\n06/19/2025\nheader repeated on each page\n\n\n3\n01/19/2025\nfooter only on the last page", +>>>>>>> main "crumbs": [ "Table Too Long" ] }, { - "objectID": "11_other_engines.html", - "href": "11_other_engines.html", - "title": "Output Engines Experimentation", + "objectID": "02_indentation.html", + "href": "02_indentation.html", + "title": "Indentation", "section": "", - "text": "Other table output options were experimented with but did not carry forward as the outputs did not render correctly. Below are the results of a few engines tried.", + "text": "The example table evaluates Indentation.\n\nlibrary(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n gt::fmt_markdown(columns = label) |> \n gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |> \n gt::sub_missing(missing_text = \"\") |> \n # Indentation\n gt::text_transform(\n locations = gt::cells_body(columns = label, rows = !row_type %in% \"label\"),\n fn = function(x) paste0(strrep(\"\\U00A0\", times = 2), x)\n ) |> \n gt::text_transform(\n locations = gt::cells_body(columns = label, rows = row_type %in% \"missing\"),\n fn = function(x) paste0(strrep(\"\\U00A0\", times = 4), x)\n ) \n\ngt_table\n\n\n\n\n\nThis is the caption\n\n\n\n\n\n\n\n\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\n      Unknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\n  I\n68 (34%)\n35 (36%)\n33 (32%)\n\n\n  II\n68 (34%)\n32 (33%)\n36 (35%)\n\n\n  III\n64 (32%)\n31 (32%)\n33 (32%)\n\n\n      Unknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/indentations_gt_pdf.pdf\")\n\nPreview the Output - no issues\n\n\n\n\ngt_table\n\nPreview the Output - no issues\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/indentation_gt_word.docx\")\n\nPreview the Output\n\ncell contents replaced with html code\n\n\n # <md_container><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space=\"preserve\">Unknown</w:t></w:r></w:p></md_container>\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nNo indentation applied\n\n\n\n\n\ngt_table\n\nPreview the Output the Output](outputs/indentations_word.docx) - cell contents replaced with html code", "crumbs": [ - "Other Engines" + "Indentation" ] }, { +<<<<<<< HEAD + "objectID": "02_indentation.html#testing-indentation-output", + "href": "02_indentation.html#testing-indentation-output", + "title": "Indentation", + "section": "", + "text": "The example table evaluates Indentation.\n\nlibrary(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age\")) |> add_overall()\n\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption\")) |> \n gt::fmt_markdown(columns = label) |> \n gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |> \n gt::sub_missing(missing_text = \"\") |> \n # Indentation\n gt::text_transform(\n locations = gt::cells_body(columns = label, rows = !row_type %in% \"label\"),\n fn = function(x) paste0(strrep(\"\\U00A0\", times = 2), x)\n ) |> \n gt::text_transform(\n locations = gt::cells_body(columns = label, rows = row_type %in% \"missing\"),\n fn = function(x) paste0(strrep(\"\\U00A0\", times = 4), x)\n ) \n\ngt_table\n\n\n\n\n\nThis is the caption\n\n\n\n\n\n\n\n\nlabel\nstat_0\nstat_1\nstat_2\n\n\n\n\nAge\n47 (38, 57)\n46 (37, 60)\n48 (39, 56)\n\n\n      Unknown\n11\n7\n4\n\n\nGrade\n\n\n\n\n\n\n\n\n  I\n68 (34%)\n35 (36%)\n33 (32%)\n\n\n  II\n68 (34%)\n32 (33%)\n36 (35%)\n\n\n  III\n64 (32%)\n31 (32%)\n33 (32%)\n\n\n      Unknown\n0\n0\n0\n\n\n\n\n\n\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/pdf/indentations_gt_pdf.pdf\")\n\nPreview the Output - no issues\n\n\n\n\ngt_table\n\nPreview the Output - no issues\n\n\n\n\ngt::gtsave(gt_table, filename = \"outputs/docx/indentation_gt_word.docx\")\n\nPreview the Output\n\ncell contents replaced with html code\n\n\n # <md_container><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space=\"preserve\">Unknown</w:t></w:r></w:p></md_container>\n\n\n\n\n\ngt_table\n\nPreview the Output\n\nNo indentation applied\n\n\n\n\n\ngt_table\n\nPreview the Output the Output](outputs/indentations_word.docx) - cell contents replaced with html code", +======= "objectID": "11_other_engines.html#typst-pdf", "href": "11_other_engines.html#typst-pdf", "title": "Output Engines Experimentation", "section": "Typst PDF", "text": "Typst PDF\n\nlibrary(gtsummary)\ntbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = \"always\", label = list(age = \"Age \\n\\U00A0\\U00A0linebreak in a cell\")) |> add_overall()\ngt_table <- tbl$table_body |> \n gt::gt(caption = gt::md(\"This is the caption \\n[Used for cross referencing in Quarto]\")) |> \n gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body\n # Column headers with line breaks\n gt::cols_label(\n stat_0 = gt::md(\"**Overall**\"),\n stat_1 = gt::md(\"**Drug A** \\nManual Line Break\"), \n stat_2 = gt::md(\"**Drug B** \\nManual Line Break\")\n ) |> \n gt::tab_header(gt::md(\"This is the Title \\nwith a linebreak\"), subtitle = \"This is the Subtitle\")\n\ngt_table\n\n\nPreview the Output\n\n{{< pdf outputs/quarto_typst.pdf width=100% height=800 >}}", +>>>>>>> main "crumbs": [ - "Other Engines" + "Indentation" ] } ] \ No newline at end of file