forked from shannonpileggi/gtreg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
207 lines (158 loc) · 5.99 KB
/
README.Rmd
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# gtreg
<!-- badges: start -->
[](https://github.com/shannonpileggi/gtreg/actions)
[](https://app.codecov.io/gh/shannonpileggi/gtreg?branch=main)
[](https://CRAN.R-project.org/package=gtreg)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
## Installation
You can install the development version of {gtreg} from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("shannonpileggi/gtreg")
```
## Overview
The {gtreg} package creates tabular data summaries appropriate for regulatory submissions.
The package builds the tables using {gtsummary}.
## Functions for adverse event (AE) reporting
**Summarize Raw Adverse Counts**
`tbl_ae_count()` provides counts of all AEs, and omits percentage statistics as multiple AEs
can occur per subject.
```{r example2}
library(gtreg)
tbl_ae_count <-
df_adverse_events |>
tbl_ae_count(
ae = adverse_event,
soc = system_organ_class,
by = drug_attribution
) |>
add_overall(across = "by") |>
modify_spanning_header(all_ae_cols() ~ "**Drug Attribution**") |>
bold_labels()
```
```{r example-tbl_ae_count, include = FALSE}
# Had to manually save images in temp file, not sure if better way.
gt::gtsave(as_gt(tbl_ae_count), file = file.path(tempdir(), "temp2.png"))
```
```{r out.width = "76%", echo = FALSE}
# Have to do this workaround since the README needs markdown format for GitHub page but a different format for the website.
if (identical(Sys.getenv("IN_PKGDOWN"), "true")) {
as_gt(tbl)
} else {
knitr::include_graphics("man/figures/README-example-tbl_ae_count-1.png")
}
```
**Summarize Adverse Events by Grade**
`tbl_ae()` counts one AE per subject by maximum grade; percentage statistics are provided by default with
the denominators reflecting the number of patients in the study.
```{r example}
library(gtreg)
gtsummary::theme_gtsummary_compact()
tbl_ae <-
df_adverse_events |>
tbl_ae(
id_df = df_patient_characteristics,
id = patient_id,
ae = adverse_event,
soc = system_organ_class,
by = grade,
strata = trt
) |>
modify_header(all_ae_cols() ~ "**Grade {by}**") |>
bold_labels()
```
```{r example-tbl_ae, include = FALSE}
# Had to manually save images in temp file, not sure if better way.
gt::gtsave(as_gt(tbl_ae), file = file.path(tempdir(), "temp.png"))
```
```{r out.width = "100%", echo = FALSE}
# Have to do this workaround since the README needs markdown format for GitHub page but a different format for the website.
if (identical(Sys.getenv("IN_PKGDOWN"), "true")) {
as_gt(tbl)
} else {
knitr::include_graphics("man/figures/README-example-tbl_ae-1.png")
}
```
**Focus on rates of high grade complications**
`tbl_ae_focus()` also counts one AE per subject by maximum grade, and is a convenience
to summarize dichotomous AE attributes.
```{r example3}
tbl_ae_focus <-
df_adverse_events |>
tbl_ae_focus(
id_df = df_patient_characteristics,
id = patient_id,
ae = adverse_event,
include = c(any_complication, grade3_complication)
)
```
```{r example-tbl_ae_focus, include = FALSE}
# Had to manually save images in temp file, not sure if better way.
gt::gtsave(as_gt(tbl_ae_focus), file = file.path(tempdir(), "temp3.png"))
```
```{r out.width = "62%", echo = FALSE}
# Have to do this workaround since the README needs markdown format for GitHub page but a different format for the website.
if (identical(Sys.getenv("IN_PKGDOWN"), "true")) {
as_gt(tbl)
} else {
knitr::include_graphics("man/figures/README-example-tbl_ae_focus-1.png")
}
```
## Other Functions for Clinical Reporting
**Regulatory summary**
`tbl_reg_summary()` creates a data summary table often seen in regulatory submissions.
```{r example4}
tbl_reg_summary <-
df_patient_characteristics |>
tbl_reg_summary(by = trt, include = c(marker, status))
```
```{r example-tbl_reg_summary, include = FALSE}
# Had to manually save images in temp file, not sure if better way.
gt::gtsave(as_gt(tbl_reg_summary), file = file.path(tempdir(), "temp4.png"))
```
```{r out.width = "42%", echo = FALSE}
# Have to do this workaround since the README needs markdown format for GitHub page but a different format for the website.
if (identical(Sys.getenv("IN_PKGDOWN"), "true")) {
as_gt(tbl)
} else {
knitr::include_graphics("man/figures/README-example-tbl_reg_summary-1.png")
}
```
**Print an AE listing**
`tbl_listing()` creates a gtsummary-class listing of data to enable grouped printing.
```{r example5}
tbl_listing <-
head(df_adverse_events, n = 10) |>
select(system_organ_class, adverse_event, grade, drug_attribution, patient_id) |>
dplyr::arrange(adverse_event, desc(grade)) |>
tbl_listing(group_by = system_organ_class) |>
bold_labels()
```
```{r example-tbl_listing, include = FALSE}
# Had to manually save images in temp file, not sure if better way.
gt::gtsave(as_gt(tbl_listing), file = file.path(tempdir(), "temp5.png"))
```
```{r out.width = "62%", echo = FALSE}
# Have to do this workaround since the README needs markdown format for GitHub page but a different format for the website.
if (identical(Sys.getenv("IN_PKGDOWN"), "true")) {
as_gt(tbl)
} else {
knitr::include_graphics("man/figures/README-example-tbl_listing-1.png")
}
```
## Code of Conduct
Please note that the gtreg project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.