Skip to content

Commit c5b0981

Browse files
committed
render ReadME
1 parent 97d4874 commit c5b0981

File tree

1 file changed

+59
-23
lines changed

1 file changed

+59
-23
lines changed

README.md

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1+
---
2+
output: github_document
3+
---
14

25
<!-- README.md is generated from README.Rmd. Please edit that file -->
36

47
# pager
58

69
<!-- badges: start -->
7-
8-
[![Lifecycle:
9-
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
10-
[![CRAN
11-
status](https://www.r-pkg.org/badges/version/pager)](https://CRAN.R-project.org/package=pager)
10+
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
11+
[![CRAN status](https://www.r-pkg.org/badges/version/pager)](https://CRAN.R-project.org/package=pager)
1212
[![R-CMD-check](https://github.com/insightsengineering/pager/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/insightsengineering/pager/actions/workflows/R-CMD-check.yaml)
13-
[![Codecov test
14-
coverage](https://codecov.io/gh/insightsengineering/pager/graph/badge.svg)](https://app.codecov.io/gh/insightsengineering/pager)
13+
[![Codecov test coverage](https://codecov.io/gh/insightsengineering/pager/graph/badge.svg)](https://app.codecov.io/gh/insightsengineering/pager)
1514
<!-- badges: end -->
1615

17-
The pager package makes it simple to save tables of class gtsummary, gt,
18-
and flextable as a Word document using a reference document. This is
19-
accomplished by creating the document via R markdown using the
20-
`reference_docx:` field.
16+
The pager package makes it simple to save tables and plots as Word, HTML, or plain text documents.
17+
Tables of class `gtsummary`, `gt`, and `flextable`, as well as `ggplot` and `grob` plots, are supported.
18+
This is accomplished by rendering the objects via R Markdown.
2119

22-
The package also supports lists of table objects. When a list is passed,
23-
a page break is placed between each table in the list.
20+
The package also supports lists of objects.
21+
When a list is passed, each element is placed on a separate page (Word), separated by a horizontal rule (HTML), or separated by a horizontal rule (plain text).
2422

2523
## Installation
2624

27-
You can install the development version of pager from
28-
[GitHub](https://github.com/) with:
25+
You can install the development version of pager from [GitHub](https://github.com/) with:
2926

3027
``` r
3128
# install.packages("pak")
@@ -34,14 +31,14 @@ pak::pak("insightsengineering/pager")
3431

3532
## Example
3633

37-
To begin, lets create a summary table.
34+
To begin, let's create a summary table.
3835

3936
``` r
4037
library(pager)
4138

4239
# create table
4340
tbl <-
44-
cards::ADAE[1:150,] |>
41+
cards::ADAE[1:150, ] |>
4542
gtsummary::tbl_hierarchical(
4643
variables = c(AESOC, AETERM),
4744
by = TRTA,
@@ -50,20 +47,59 @@ tbl <-
5047
)
5148
```
5249

53-
The code below will save the table as Word document using the default
54-
portrait orientation reference document.
50+
### Word (.docx)
51+
52+
The code below will save the table as a Word document using the default portrait orientation reference document.
5553

5654
``` r
5755
gtsummary::as_flex_table(tbl) |>
58-
save_with_rmarkdown(path = tempfile(fileext = ".docx"))
59-
#> ✔ Writing '/var/folders/6f/gdjf_vxj2wl3jhmxdkd1hd_w0000gn/T//RtmpcdsRdZ/filee351225cee86.docx'
56+
save_docx(path = tempfile(fileext = ".docx"))
6057
```
6158

6259
The example below first splits the summary table into a list of tables.
6360
Each table is saved to a separate page in the resulting Word document.
6461

6562
``` r
6663
gtsummary::tbl_split_by_rows(tbl, row_numbers = seq(20, nrow(tbl), by = 20)) |>
67-
save_with_rmarkdown(path = tempfile(fileext = ".docx"))
68-
#> ✔ Writing '/var/folders/6f/gdjf_vxj2wl3jhmxdkd1hd_w0000gn/T//RtmpcdsRdZ/filee35112a6c071.docx'
64+
save_docx(path = tempfile(fileext = ".docx"))
65+
```
66+
67+
### HTML (.html)
68+
69+
The code below will save the table as a self-contained HTML file.
70+
71+
``` r
72+
tbl |>
73+
gtsummary::as_gt() |>
74+
save_html(path = tempfile(fileext = ".html"))
75+
```
76+
77+
A paginated table can also be saved as HTML — each page is separated by a horizontal rule.
78+
79+
``` r
80+
gtsummary::tbl_split_by_rows(tbl, row_numbers = seq(20, nrow(tbl), by = 20)) |>
81+
save_html(path = tempfile(fileext = ".html"))
82+
```
83+
84+
### Plain text (.txt)
85+
86+
The code below will save the table as a plain text (Markdown-formatted) file.
87+
88+
``` r
89+
tbl |>
90+
save_txt(path = tempfile(fileext = ".txt"))
91+
```
92+
93+
`save_txt()` also accepts `gt` tables directly.
94+
95+
``` r
96+
gt::gt(head(mtcars)) |>
97+
save_txt(path = tempfile(fileext = ".txt"))
98+
```
99+
100+
A list of tables can also be saved as plain text — each table is separated by a horizontal rule.
101+
102+
``` r
103+
list(gt::gt(head(mtcars)), gt::gt(tail(mtcars))) |>
104+
save_txt(path = tempfile(fileext = ".txt"))
69105
```

0 commit comments

Comments
 (0)