-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_indentation.qmd
80 lines (57 loc) · 1.92 KB
/
02_indentation.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
title: "Indentation"
format: html
editor: visual
---
## Testing Indentation output
The example table evaluates Indentation.
```{r}
library(gtsummary)
tbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = "always", label = list(age = "Age")) |> add_overall()
gt_table <- tbl$table_body |>
gt::gt(caption = gt::md("This is the caption")) |>
gt::fmt_markdown(columns = label) |>
gt::cols_hide(columns = c(variable, var_type, row_type, var_label)) |>
gt::sub_missing(missing_text = "") |>
# Indentation
gt::text_transform(
locations = gt::cells_body(columns = label, rows = !row_type %in% "label"),
fn = function(x) paste0(strrep("\U00A0", times = 2), x)
) |>
gt::text_transform(
locations = gt::cells_body(columns = label, rows = row_type %in% "missing"),
fn = function(x) paste0(strrep("\U00A0", times = 4), x)
)
```
### gt_save PDF
```{r eval = FALSE}
gt::gtsave(gt_table, filename = "outputs/pdf/indentations_gt_pdf.pdf")
```
[Preview the Output](outputs/pdf/indentations_gt_pdf.pdf)
- no issues
### rmarkdown rendered PDF
```{r eval = FALSE}
gt_table
```
[Preview the Output](outputs/pdf/indentation_rmd_pdf.pdf)
- no issues
### gt_save rendered word file
```{r eval = FALSE}
gt::gtsave(gt_table, filename = "outputs/docx/indentation_gt_word.docx")
```
[Preview the Output](outputs/docx/indentation_gt_word.docx)
- cell contents replaced with html code
```{html}
# <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>
```
### quarto rendered word file
```{r eval = FALSE}
gt_table
```
[Preview the Output](outputs/docx/indentation_qmd_word.docx)
- No indentation applied
### rmarkdown rendered word file
```{r eval = FALSE}
gt_table
```
[Preview the Output](outputs/docx/indentation_rmd_word.docx) the Output\](outputs/indentations_word.docx) - cell contents replaced with html code