Skip to content

Commit 384a01c

Browse files
Merge pull request #376 from Merck/vignette-style
Improve boundary update vignette code style
2 parents b690cc1 + 9b56345 commit 384a01c

File tree

1 file changed

+54
-46
lines changed

1 file changed

+54
-46
lines changed

vignettes/articles/story-update-boundary.Rmd

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ knitr::opts_chunk$set(echo = TRUE)
2222

2323
```{r, message=FALSE, warning=FALSE}
2424
library(gsDesign2)
25-
library(tibble)
2625
library(gt)
27-
library(dplyr)
2826
```
2927

3028
# Design assumptions
@@ -118,13 +116,13 @@ over the targeted 90\%.
118116
x |>
119117
summary() |>
120118
as_gt() |>
121-
gt::tab_header(title = "Original design") |>
122-
gt::tab_style(
119+
tab_header(title = "Original design") |>
120+
tab_style(
123121
style = list(
124-
gt::cell_fill(color = "lightcyan"),
125-
gt::cell_text(weight = "bold")
122+
cell_fill(color = "lightcyan"),
123+
cell_text(weight = "bold")
126124
),
127-
locations = gt::cells_body(
125+
locations = cells_body(
128126
columns = Z,
129127
rows = Bound == "Efficacy"
130128
)
@@ -152,32 +150,37 @@ observed_data <- simtrial::sim_pw_surv(
152150
)
153151
154152
observed_data_ia <- observed_data |> simtrial::cut_data_by_date(analysis_time[1])
155-
observed_data_fa <- observed_data |> simtrial::cut_data_by_date(analysis_time[2])
153+
observed_data_fa <- observed_data |> simtrial::cut_data_by_date(analysis_time[2])
156154
```
157155

158156
The updated design is
159157
```{r}
160-
gs_update_ahr(x = x,
161-
ia_alpha_spending = "actual_info_frac",
162-
fa_alpha_spending = "full_alpha",
163-
observed_data = list(observed_data_ia, observed_data_fa)) |>
164-
summary(col_vars = c("analysis", "bound", "z", "~hr at bound",
165-
"nominal p", "Alternate hypothesis", "Null hypothesis"),
166-
col_decimals = c(NA, NA, 4, 4, 4, 4, 4)) |>
158+
gs_update_ahr(
159+
x = x,
160+
ia_alpha_spending = "actual_info_frac",
161+
fa_alpha_spending = "full_alpha",
162+
observed_data = list(observed_data_ia, observed_data_fa)
163+
) |>
164+
summary(
165+
col_vars = c(
166+
"analysis", "bound", "z", "~hr at bound",
167+
"nominal p", "Alternate hypothesis", "Null hypothesis"
168+
),
169+
col_decimals = c(NA, NA, 4, 4, 4, 4, 4)
170+
) |>
167171
as_gt() |>
168-
gt::tab_style(
172+
tab_style(
169173
style = list(
170-
gt::cell_fill(color = "lightcyan"),
171-
gt::cell_text(weight = "bold")
174+
cell_fill(color = "lightcyan"),
175+
cell_text(weight = "bold")
172176
),
173-
locations = gt::cells_body(
177+
locations = cells_body(
174178
columns = Z,
175179
rows = Bound == "Efficacy"
176180
)
177181
)
178182
```
179183

180-
181184
# Two-sided asymmetric design, beta-spending with non-binding lower bound {.tabset}
182185

183186
In this section, we investigate a 2 sided asymmetric design, with the
@@ -232,62 +235,67 @@ larger than what we have in the 1-sided example.
232235
x |>
233236
summary() |>
234237
as_gt() |>
235-
gt::tab_header(title = "Original design") |>
236-
gt::tab_style(
238+
tab_header(title = "Original design") |>
239+
tab_style(
237240
style = list(
238-
gt::cell_fill(color = "lightcyan"),
239-
gt::cell_text(weight = "bold")
241+
cell_fill(color = "lightcyan"),
242+
cell_text(weight = "bold")
240243
),
241-
locations = gt::cells_body(
244+
locations = cells_body(
242245
columns = Z,
243246
rows = Bound == "Efficacy"
244247
)
245248
) |>
246-
gt::tab_style(
249+
tab_style(
247250
style = list(
248-
gt::cell_fill(color = "#F9E3D6"),
249-
gt::cell_text(weight = "bold")
251+
cell_fill(color = "#F9E3D6"),
252+
cell_text(weight = "bold")
250253
),
251-
locations = gt::cells_body(
254+
locations = cells_body(
252255
columns = Z,
253256
rows = Bound == "Futility"
254257
)
255258
)
256259
```
257260

258-
For simplicity in presentation, we assume the observed events are the same as that in the 1-sided design.
261+
For simplicity in presentation, we assume the observed events are the same as that in the 1-sided design.
259262

260263
The updated design is
261264
```{r}
262-
gs_update_ahr(x = x,
263-
ia_alpha_spending = "actual_info_frac",
264-
fa_alpha_spending = "full_alpha",
265-
observed_data = list(observed_data_ia, observed_data_fa)) |>
266-
summary(col_vars = c("analysis", "bound", "z", "~hr at bound",
267-
"nominal p", "Alternate hypothesis", "Null hypothesis"),
268-
col_decimals = c(NA, NA, 4, 4, 4, 4, 4)) |>
265+
gs_update_ahr(
266+
x = x,
267+
ia_alpha_spending = "actual_info_frac",
268+
fa_alpha_spending = "full_alpha",
269+
observed_data = list(observed_data_ia, observed_data_fa)
270+
) |>
271+
summary(
272+
col_vars = c(
273+
"analysis", "bound", "z", "~hr at bound",
274+
"nominal p", "Alternate hypothesis", "Null hypothesis"
275+
),
276+
col_decimals = c(NA, NA, 4, 4, 4, 4, 4)
277+
) |>
269278
as_gt() |>
270-
gt::tab_style(
279+
tab_style(
271280
style = list(
272-
gt::cell_fill(color = "lightcyan"),
273-
gt::cell_text(weight = "bold")
281+
cell_fill(color = "lightcyan"),
282+
cell_text(weight = "bold")
274283
),
275-
locations = gt::cells_body(
284+
locations = cells_body(
276285
columns = Z,
277286
rows = Bound == "Efficacy"
278287
)
279288
) |>
280-
gt::tab_style(
289+
tab_style(
281290
style = list(
282-
gt::cell_fill(color = "#F9E3D6"),
283-
gt::cell_text(weight = "bold")
291+
cell_fill(color = "#F9E3D6"),
292+
cell_text(weight = "bold")
284293
),
285-
locations = gt::cells_body(
294+
locations = cells_body(
286295
columns = Z,
287296
rows = Bound == "Futility"
288297
)
289298
)
290299
```
291300

292-
293301
# References

0 commit comments

Comments
 (0)