Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
name: Docs 📚

on:
push:
branches:
- main
paths:
- "_pkgdown.y[a]ml"
- DESCRIPTION
- "**.md"
- "**.Rmd"
- "man/**"
- "LICENSE.*"
- NAMESPACE
- "_quarto.yml"
- "index.qmd"
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- main
paths:
- "_pkgdown.y[a]ml"
- DESCRIPTION
- "**.md"
- "**.Rmd"
- "man/**"
- "LICENSE.*"
- NAMESPACE
- "_quarto.yml"
- "index.qmd"
workflow_dispatch:

jobs:
docs:
name: Quarto Docs 📕
runs-on: ubuntu-latest
container:
image: rocker/verse:4.4.0
permissions:
contents: write
steps:
- name: Check out repository 🛎️
uses: actions/checkout@v4.1.1

- name: Restore packages
shell: Rscript {0}
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::install(c("rmarkdown", "yaml"))
renv::restore()

- name: Render Quarto Project 📑
run: quarto render --output-dir _site
shell: bash

- name: Upload Docs ⬆️
if: github.event_name != 'push'
uses: actions/upload-artifact@v4
with:
name: site
path: ./_site

- name: Publish Site 🗺️
if: github.event_name != 'pull_request'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
destination_dir: "."
58 changes: 0 additions & 58 deletions .github/workflows/publish.yml

This file was deleted.

8 changes: 5 additions & 3 deletions 02_indentation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ editor: visual

The example table evaluates Indentation.

```{r}
```{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()

Expand Down Expand Up @@ -64,13 +64,13 @@ doconv::docx2pdf("outputs/docx/indentation_gt_word.docx")

###### Preview the Output

![](outputs/docx/indentation_gt_word.docx){width="80%" height="1000"}
![](outputs/docx/indentation_gt_word.pdf){width="80%" height="1000"}

| | Date | Finding |
|-----|------------|--------------------------------------|
| 1 | 06/19/2025 | cell contents replaced with xml code |

```{html}
```{html, eval= FALSE}
# <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>
```

Expand All @@ -84,6 +84,8 @@ doconv::docx2pdf("outputs/docx/indentation_qmd_word.docx")

###### Preview the Output

![](outputs/docx/indentation_qmd_word.pdf){width="80%" height="1000"}

| | Date | Finding |
|-----|------------|------------------------|
| 1 | 06/19/2025 | No indentation applied |
Expand Down
2 changes: 1 addition & 1 deletion 03_spanning_header.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ format: html
editor: visual
---

```{r}
```{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()
Expand Down
2 changes: 1 addition & 1 deletion 04_footnotes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ format: html
editor: visual
---

```{r}
```{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()
Expand Down
2 changes: 1 addition & 1 deletion 05_source_notes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ format: html
editor: visual
---

```{r}
```{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()
Expand Down
2 changes: 1 addition & 1 deletion 06_titles.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ format: html
editor: visual
---

```{r}
```{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()
Expand Down
81 changes: 81 additions & 0 deletions 13_pdf_conversion.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: "PDF Conversion Outputs"
format: html
editor: visual
---

## docx to PDF Conversion

There are limited opensource document converters available for converting tables in docx files to pdf output with high fidelity. One software explored is libreoffice. Findings from experimenting with this package:

```{r, eval=FALSE}
library(gtsummary)
library(dplyr)

set.seed(123)
data <- dplyr::tibble(
id = 1:100,
age = sample(18:90, 100, replace = TRUE),
sex = sample(c("Male", "Female"), 100, replace = TRUE),
race = sample(c("White", "Black", "Asian", "Hispanic"), 100, replace = TRUE),
bmi = round(runif(100, 18, 35), 1),
smoking_status = sample(c("Never", "Former", "Current"), 100, replace = TRUE),
diabetes = sample(c("Yes", "No"), 100, replace = TRUE),
hypertension = sample(c("Yes", "No"), 100, replace = TRUE),
heart_disease = sample(c("Yes", "No"), 100, replace = TRUE),
cancer = sample(c("Yes", "No"), 100, replace = TRUE),
cholesterol = sample(c("Normal", "High"), 100, replace = TRUE),
exercise_frequency = sample(0:7, 100, replace = TRUE),
alcohol_intake = sample(c("None", "Low", "Moderate", "High"), 100, replace = TRUE),
family_history = sample(c("Yes", "No"), 100, replace = TRUE),
education = sample(c("High School", "College", "Graduate"), 100, replace = TRUE),
marital_status = sample(c("Single", "Married", "Divorced"), 100, replace = TRUE),
employment_status = sample(c("Employed", "Unemployed", "Retired"), 100, replace = TRUE),
region = sample(c("North", "South", "East", "West"), 100, replace = TRUE),
health_insurance = sample(c("Yes", "No"), 100, replace = TRUE),
medication = sample(c("Yes", "No"), 100, replace = TRUE),
visits_last_year = sample(0:10, 100, replace = TRUE),
satisfaction = sample(1:5, 100, replace = TRUE)
)

# Create summary table
summary_table <- data %>%
tbl_summary(
by = sex, # Group by sex
statistic = list(all_continuous() ~ "{mean} ({sd})", all_categorical() ~ "{n} ({p}%)"),
label = list(
age ~ "Age (years)",
bmi ~ "BMI",
smoking_status ~ "Smoking Status",
diabetes ~ "Diabetes",
hypertension ~ "Hypertension",
heart_disease ~ "Heart Disease",
cancer ~ "Cancer",
cholesterol ~ "Cholesterol",
exercise_frequency ~ "Exercise Frequency (days/week)",
alcohol_intake ~ "Alcohol Intake",
family_history ~ "Family History",
education ~ "Education Level",
marital_status ~ "Marital Status",
employment_status ~ "Employment Status",
region ~ "Region",
health_insurance ~ "Health Insurance",
medication ~ "On Medication",
visits_last_year ~ "Visits Last Year",
satisfaction ~ "Health Satisfaction (1-5)"
)
) %>%
add_n() %>%
modify_header(label = "**Characteristic**", estimate = "**Mean (SD) or N (%)**") %>%
modify_table_styling(columns = everything())

# save as a word document
gt::gtsave(as_gt(summary_table), filename = "outputs/docx/too_long_libreoffice_word.docx")

```

Convert the word document to pdf using libreoffice

```{bash, eval = FALSE}
# soffice --headless --convert-to pdf "outputs/docx/too_long_libreoffice_word.docx" --outdir "outputs/pdf"
```
4 changes: 3 additions & 1 deletion _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -80,4 +80,6 @@ website:
text: Table Too Wide
- href: 11_other_engines.qmd
text: Other Engines
- href: 13_pdf_conversion.qmd
text: PDF Conversion
editor: source
Binary file removed _site/outputs/docx/alignment_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/alignment_qmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/alignment_rmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/bold_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/footnotes_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/footnotes_qmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/footnotes_rmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/indentation_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/indentation_rmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/linebreaks_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/linebreaks_qmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/linebreaks_rmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/source_notes_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/source_notes_qmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/source_notes_rmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/spanning_header_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/spanning_header_qmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/spanning_header_rmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/titles_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/titles_qmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/titles_rmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/too_long_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/too_long_qmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/too_long_rmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/too_wide_gt_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/too_wide_qmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/docx/too_wide_rmd_word.docx
Binary file not shown.
Binary file removed _site/outputs/pdf/alignment_gt_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/alignment_rmd_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/bold_gt_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/footnotes_gt_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/footnotes_rmd_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/indentation_rmd_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/indentations_gt_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/linebreaks_rmd_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/source_notes_rmd_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/spanning_header_gt_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/spanning_header_rmd_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/titles_gt_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/titles_rmd_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/too_long_gt_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/too_long_rmd_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/too_wide_gt_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/pdf/too_wide_rmd_pdf.pdf
Binary file not shown.
Binary file removed _site/outputs/quarto_typst.pdf
Binary file not shown.
Loading