-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtemplate-fig_01.qmd
57 lines (42 loc) · 5.05 KB
/
template-fig_01.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
---
title: FDA Figure 1
subtitle: Time to Permanent Discontinuation of Study Drug, Safety Population, Pooled Analyses
format: html
---
::: panel-tabset
## Spec. Screenshot
{fig-align="center"}
## ggplot2 Figure
```{r fig, message=FALSE, warning=FALSE}
# Load Libraries & Data
library(cardinal)
adsl <- random.cdisc.data::cadsl
adsl$TRTSDTM <- adsl$TRTSDTM[1]
adsl$TRTEDTM <- adsl$TRTSDTM + lubridate::days(sample(0:400, nrow(adsl), replace = TRUE))
# Output Figure
make_fig_01(df = adsl)
```
## Figure Setup
```{r fig, eval=FALSE, echo=TRUE}
```
## Function Details
### `make_fig_01()`
------------------------------------------------------------------------
Required variables:
- **`df`**: The variables specified by `arm_var`, `id_var`, `saffl_var`, `trtsdtm_var`, and `trtedtm_var`.
| **Argument** | **Description** | **Default** |
|:--------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------|
| `df` | (`data.frame`) Dataset (typically ADSL) required to build table. | *No default* |
| `arm_var` | (`character`) Arm variable used to split table into columns. | `"ARM"` |
| `saffl_var` | (`character`) Flag variable used to indicate inclusion in safety population. | `"SAFFL"` |
| `id_var` | (`character`) Identifier variable used to count the participants within each flag. | `"USUBJID"` |
| `trtsdtm_var` | (`character`) Treatment start datetime variable in df. | `"TRTSDTM"` |
| `trtedtm_var` | (`character`) Treatment end datetime variable in df. | `"TRTEDTM"` |
| `u_trtdur` | (`character`) Unit for duration of treatment. Options are `"days"`, `"weeks"`, `"months"` and `"years"`. | `"days"` |
| `x_lab` | (`character`) x-axis label. | `paste0("Time from first dose (", u_trtdur, ")")` |
| `y_lab` | (`character`) y-axis label. | `"Percent of Patients (%)"` |
| `xticks` | (`vector` of `numeric`) x-axis tick positions. If `NA` (default), tick mark positions are automatically calculated. | `NA` |
| `add_table` | (`flag`) whether "Number of Patients" table should be printed under the plot. | `TRUE` |
| `annotations` | (named `list` of `character`) List of annotations to add to the table. Valid annotation types are `title`, `subtitles`, and `caption`. Each name-value pair should use the annotation type as name and the desired string as value. | `NULL` |
Source code for this function is available [here](https://github.com/pharmaverse/cardinal/blob/main/R/fda-fig_01.R).
:::