We will here use:
- the enrollment_period_plot
function in the Data &
Functions page (Download
enrollment_period_plot.R)
- datasets from an Rdata file:
Download
datasets
The simplest example is to represent enrollment period of a small dataset (long format):
# source the function
source("enrollment_period_plot.R", encoding = "latin1")
# create the database
base_long <- data.frame(
start = c("10/11/2018", "01/11/2012", "02/04/2014", "20/06/2016", "24/09/2013"),
end = c("20/10/2019", "07/10/2014", "03/08/2022", "13/08/2022", "30/08/2017"),
arm = c("exp", "exp", "exp", "exp", "ctrl"),
record_id = 1:5) %>%
mutate(
start = start %>% as.Date("%d/%m/%Y"),
end = end %>% as.Date("%d/%m/%Y")
)
We also can use more options if a dataframe as this columns:
- group : for a subset
- prim_endp : for the primary endpoint :
Positive/ Negative/ Unclear/ No PE defined
| record_id | start | end | arm | group | prim_endp |
|---|---|---|---|---|---|
| 1 | 2015 | 2020 | exp | Balancing-based methods | Positive |
| 1 | 2016 | 2020 | ctrl | Balancing-based methods | Positive |
| 2 | 2020 | NA | exp | Balancing-based methods | No PE defined |
| 2 | 2019 | 2020 | ctrl | Balancing-based methods | No PE defined |
# source the function
source("enrollment_period_plot.R", encoding = "latin1")
# load database
load("data_enrollment_period_example.Rdata")
# plot with base_wide
enrollment_period_plot(baz_wide = base_wide, group_filter = 'Balancing-based methods')
| record_id | start_exp | end_exp | start_ctrl | end_ctrl | group | prim_endp |
|---|---|---|---|---|---|---|
| 1 | 2015 | 2020 | 2016 | 2020 | Balancing-based methods | Positive |
| 2 | 2020 | NA | 2019 | 2020 | Balancing-based methods | No PE defined |
| 3 | 2017 | 2020 | NA | NA | Non-balancing methods | Positive |
| 4 | NA | NA | 2003 | 2018 | Balancing-based methods | Positive |
# source the function
source("enrollment_period_plot.R", encoding = "latin1")
# load database
load("data_enrollment_period_example.Rdata")
# plot with base_long
enrollment_period_plot(baz_long = base_long, group_filter = 'Balancing-based methods')
This document is a work of the statistics team in the Biostatistics and Medical Information Department at Saint-Louis Hospital in Paris (SBIM).
This site was developed by Emma Lafaurie.
Actual development and updating by Noémie Bigot and Anouk Walter-Petrich
noemie.bigot@aphp.fr; anouk.walter-petrich@u-paris.fr.
Based on The R Graph Gallery by Yan Holtz.