Skip to content

Commit 32e60fd

Browse files
ayogasekaramdependabot-preview[bot]edelarua
authored
add lbt01 template (#310)
* add lbt01 template * update LBT01 with multiple params * add crane to description * [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update * remove source note modification * add labelled to imports * Minor updates, added some more comments * Fix section level in getting started doc * Update folder name * Add Roche tag * update tbl name * delete markdown file --------- Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Emily de la Rua <emily.de_la_rua@contractors.roche.com>
1 parent 2854743 commit 32e60fd

4 files changed

Lines changed: 92 additions & 2 deletions

File tree

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Imports:
2222
ggsurvfit (>= 1.1.0),
2323
gt (>= 1.0.0),
2424
gtsummary (>= 2.4.0),
25+
labelled (>= 2.14.0),
2526
lubridate (>= 1.7.10),
2627
purrr (>= 1.0.1),
2728
rlang (>= 0.4.11),
@@ -39,4 +40,4 @@ Encoding: UTF-8
3940
Language: en-US
4041
LazyData: true
4142
Roxygen: list(markdown = TRUE)
42-
RoxygenNote: 7.3.2
43+
RoxygenNote: 7.3.3
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Laboratory Test Results and Change from Baseline by Visit
3+
subtitle: Roche LBT01
4+
categories: [table, Roche, parallel-group, change from baseline]
5+
---
6+
7+
::: panel-tabset
8+
## Table Preview
9+
10+
```{r img, echo=FALSE, fig.align='center', out.width='60%'}
11+
knitr::include_graphics("result.png")
12+
```
13+
14+
## Setup
15+
16+
```{r setup, message=FALSE}
17+
# Load libraries & data -------------------------------------
18+
library(gtsummary)
19+
library(dplyr)
20+
library(crane)
21+
22+
adsl <- random.cdisc.data::cadsl
23+
adlb <- random.cdisc.data::cadlb
24+
25+
# Pre-processing --------------------------------------------
26+
data <- adlb |>
27+
dplyr::filter(
28+
SAFFL == "Y", # safety population
29+
AVISITN >= 0 # only keep valid visits
30+
) |>
31+
# retain the "WEEK *" portion of the visit
32+
dplyr::mutate(
33+
AVISIT = if_else(
34+
stringr::str_detect(AVISIT, "WEEK"),
35+
stringr::str_extract(AVISIT, "WEEK \\d+"),
36+
AVISIT
37+
) |> trimws()
38+
)
39+
```
40+
41+
## Build Table
42+
43+
```{r tbl, results='hide'}
44+
tbl <- data |>
45+
filter(
46+
AVISIT %in% c("BASELINE", "WEEK 5") # specify visits to display in table
47+
) |>
48+
# apply tbl_baseline_chg function to each level of PARAM in the data
49+
gtsummary::tbl_strata_nested_stack(
50+
strata = PARAM,
51+
~ .x |>
52+
crane::tbl_baseline_chg(
53+
baseline_level = "BASELINE",
54+
by = "TRT01A",
55+
denominator = adsl
56+
)
57+
) |>
58+
# bold lab test labels
59+
gtsummary::modify_bold(columns = label, rows = tbl_indent_id1 > 0L) |>
60+
# update header labels
61+
gtsummary::modify_header(label = "**Lab \n\U00A0\U00A0\U00A0\U00A0 Visit**") |>
62+
gtsummary::modify_spanning_header(gtsummary::all_stat_cols() ~ "**{level}** \nN = {n}")
63+
64+
tbl
65+
```
66+
67+
```{r eval=FALSE, include=FALSE}
68+
gt::gtsave(as_gt(tbl), filename = "result.png")
69+
```
70+
71+
```{r img, echo=FALSE, fig.align='center', out.width='60%'}
72+
```
73+
74+
## Build ARD
75+
76+
```{r ard, message=FALSE, warning=FALSE, results='hide'}
77+
# Extract ARD from previously created gtsummary table (refer to "Build Table")
78+
ard <- gather_ard(tbl)
79+
80+
# Output ARD
81+
ard
82+
```
83+
84+
```{r, echo=FALSE}
85+
# Print ARD
86+
withr::local_options(width = 9999)
87+
print(ard, columns = "all")
88+
```
89+
:::
199 KB
Loading

quarto/getting_started.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (!require("crane")) install.packages("crane")
3131

3232
For more information on these packages, see the [Additional Resources](#additional-resources) section below.
3333

34-
#### Creating Your TLG Template
34+
### Creating Your TLG Template
3535

3636
When adding a new template, start by initializing a new folder in the `quarto/catalog` folder with a name that uniquely identifies your TLG (e.g. `fda-table_01`, `lab-tests-summary`). Within this folder, add a file named `index.qmd` which will contain your new TLG template. To simplify the template-creation process we have provided an empty template file (`inst/empty-template.qmd`) which can be copied into your new `index.qmd` file and then modified.
3737

0 commit comments

Comments
 (0)