adsl <- r2rtf::r2rtf_adsl
adsl$TRTA <- adsl$TRT01A
adsl$TRTA <- factor(adsl$TRTA,
levels = c("Placebo", "Xanomeline Low Dose", "Xanomeline High Dose"),
labels = c("Placebo", "Low Dose", "High Dose")
)
# Create a variable EOSSTT indicating the end of end of study status
adsl$EOSSTT <- sample(x = c("Participants Ongoing", "Discontinued"),
size = length(adsl$USUBJID),
prob = c(0.8, 0.2), replace = TRUE)
# Create a variable EOTSTT1 indicating the end of treatment status part 1
adsl$EOTSTT1 <- sample(x = c("Completed", "Discontinued"),
size = length(adsl$USUBJID),
prob = c(0.85, 0.15), replace = TRUE)
plan <- plan(
analysis = "base_char", population = "apat",
observation = "apat", parameter = "age;gender;race"
) |>
add_plan(
analysis = "disp", population = "apat",
observation = "apat", parameter = "disposition;medical-disposition"
) |>
add_plan(
analysis = "trt_compliance", population = "apat",
observation = "apat", parameter = "comp8;comp16;comp24"
)
meta <- meta_adam(
population = adsl,
observation = adsl
) |>
define_plan(plan = plan) |>
define_population(
name = "apat",
group = "TRTA",
subset = quote(SAFFL == "Y"),
var = c("USUBJID", "TRTA", "SAFFL", "AGEGR1", "SEX", "RACE", "EOSSTT", "EOTSTT1", "COMP8FL", "COMP16FL", "COMP24FL")
) |>
define_parameter(
name = "age",
var = "AGE",
label = "Age (years)",
vargroup = "AGEGR1"
) |>
define_parameter(
name = "gender",
var = "SEX",
label = "Gender"
) |>
define_parameter(
name = "race",
var = "RACE",
label = "Race"
) |>
define_parameter(
name = "disposition",
var = "EOSSTT",
label = "Trial Disposition"
) |>
define_parameter(
name = "medical-disposition",
var = "EOTSTT1",
label = "Participant Study Medication Disposition"
) |>
metalite::define_parameter(
name = "comp8",
var = "COMP8FL",
label = "Compliance (Week 8)",
) |>
metalite::define_parameter(
name = "comp16",
var = "COMP16FL",
label = "Compliance (Week 16)",
) |>
metalite::define_parameter(
name = "comp24",
var = "COMP24FL",
label = "Compliance (Week 24)",
) |>
define_analysis(
name = "base_char",
title = "Participant Baseline Characteristics by Treatment Group",
label = "baseline characteristic table"
) |>
define_analysis(
name = "trt_compliance",
title = "Summary of Treatment Compliance",
label = "treatment compliance table"
) |>
define_analysis(
name = "disp",
title = "Disposition of Participant",
label = "disposition table"
) |>
meta_build()
Prepare the numbers
## List of 14
## $ meta :List of 7
## $ population : chr "apat"
## $ observation : chr "apat"
## $ parameter : chr "age;gender;race"
## $ n :'data.frame': 1 obs. of 6 variables:
## $ order : NULL
## $ group : chr "TRTA"
## $ reference_group: NULL
## $ char_n :List of 3
## $ char_var : chr [1:3] "AGE" "SEX" "RACE"
## $ char_prop :List of 3
## $ var_type :List of 3
## $ group_label : Factor w/ 3 levels "Placebo","Low Dose",..: 1 3 2
## $ analysis : chr "base_char"
## name n_1 n_2 n_3 n_9999 var_label
## 1 Participants in population 86 84 84 254 -----
## [[1]]
## name Placebo Low Dose High Dose Total var_label
## 1 <65 14 8 11 33 Age (years)
## 2 >80 30 29 18 77 Age (years)
## 3 65-80 42 47 55 144 Age (years)
## 4 <NA> <NA> <NA> <NA> <NA> Age (years)
## 5 Mean 75.2 75.7 74.4 75.1 Age (years)
## 6 SD 8.6 8.3 7.9 8.2 Age (years)
## 7 SE 0.9 0.9 0.9 0.5 Age (years)
## 8 Median 76.0 77.5 76.0 77.0 Age (years)
## 9 Min 52.0 51.0 56.0 51.0 Age (years)
## 10 Max 89.0 88.0 88.0 89.0 Age (years)
## 11 Q1 to Q3 69.25 to 81.75 71 to 82 70.75 to 80 70 to 81 Age (years)
## 12 Range 52 to 89 51 to 88 56 to 88 51 to 89 Age (years)
##
## [[2]]
## name Placebo Low Dose High Dose Total var_label
## 1 F 53 50 40 143 Gender
## 2 M 33 34 44 111 Gender
##
## [[3]]
## name Placebo Low Dose High Dose Total var_label
## 1 AMERICAN INDIAN OR ALASKA NATIVE 0 0 1 1 Race
## 2 BLACK OR AFRICAN AMERICAN 8 6 9 23 Race
## 3 WHITE 78 78 74 230 Race
## [1] "AGE" "SEX" "RACE"
## [[1]]
## name Placebo Low Dose High Dose Total var_label
## 1 <65 16.27907 9.52381 13.09524 12.99213 Age (years)
## 2 >80 34.88372 34.52381 21.42857 30.31496 Age (years)
## 3 65-80 48.83721 55.95238 65.47619 56.69291 Age (years)
## 4 <NA> NA NA NA NA Age (years)
## 5 Mean NA NA NA NA Age (years)
## 6 SD NA NA NA NA Age (years)
## 7 SE NA NA NA NA Age (years)
## 8 Median NA NA NA NA Age (years)
## 9 Min NA NA NA NA Age (years)
## 10 Max NA NA NA NA Age (years)
## 11 Q1 to Q3 NA NA NA NA Age (years)
## 12 Range NA NA NA NA Age (years)
##
## [[2]]
## name Placebo Low Dose High Dose Total var_label
## 1 F 61.62791 59.52381 47.61905 56.29921 Gender
## 2 M 38.37209 40.47619 52.38095 43.70079 Gender
##
## [[3]]
## name Placebo Low Dose High Dose Total
## 1 AMERICAN INDIAN OR ALASKA NATIVE 0.000000 0.000000 1.190476 0.3937008
## 2 BLACK OR AFRICAN AMERICAN 9.302326 7.142857 10.714286 9.0551181
## 3 WHITE 90.697674 92.857143 88.095238 90.5511811
## var_label
## 1 Race
## 2 Race
## 3 Race
outdata <- outdata |> format_base_char(display_col = c("n", "prop", "total"), digits_prop = 2)
outdata$tbl
## name n_1 p_1 n_2 p_2
## 1 Participants in population 86 <NA> 84 <NA>
## 2 <65 14 (16.28) 8 (9.52)
## 3 >80 30 (34.88) 29 (34.52)
## 4 65-80 42 (48.84) 47 (55.95)
## 5 <NA> <NA> <NA> <NA> <NA>
## 6 Mean 75.2 <NA> 75.7 <NA>
## 7 SD 8.6 <NA> 8.3 <NA>
## 8 SE 0.9 <NA> 0.9 <NA>
## 9 Median 76.0 <NA> 77.5 <NA>
## 10 Q1 to Q3 69.25 to 81.75 <NA> 71 to 82 <NA>
## 11 Range 52 to 89 <NA> 51 to 88 <NA>
## 12 F 53 (61.63) 50 (59.52)
## 13 M 33 (38.37) 34 (40.48)
## 14 AMERICAN INDIAN OR ALASKA NATIVE 0 (0.00) 0 (0.00)
## 15 BLACK OR AFRICAN AMERICAN 8 (9.30) 6 (7.14)
## 16 WHITE 78 (90.70) 78 (92.86)
## n_3 p_3 n_9999 p_9999 var_label
## 1 84 <NA> 254 <NA> -----
## 2 11 (13.10) 33 (12.99) Age (years)
## 3 18 (21.43) 77 (30.31) Age (years)
## 4 55 (65.48) 144 (56.69) Age (years)
## 5 <NA> <NA> <NA> <NA> Age (years)
## 6 74.4 <NA> 75.1 <NA> Age (years)
## 7 7.9 <NA> 8.2 <NA> Age (years)
## 8 0.9 <NA> 0.5 <NA> Age (years)
## 9 76.0 <NA> 77.0 <NA> Age (years)
## 10 70.75 to 80 <NA> 70 to 81 <NA> Age (years)
## 11 56 to 88 <NA> 51 to 89 <NA> Age (years)
## 12 40 (47.62) 143 (56.30) Gender
## 13 44 (52.38) 111 (43.70) Gender
## 14 1 (1.19) 1 (0.39) Race
## 15 9 (10.71) 23 (9.06) Race
## 16 74 (88.10) 230 (90.55) Race
outdata <- outdata |> format_base_char(display_col = c("n", "prop"), digits_prop = 3)
outdata$tbl
## name n_1 p_1 n_2 p_2
## 1 Participants in population 86 <NA> 84 <NA>
## 2 <65 14 (16.279) 8 (9.524)
## 3 >80 30 (34.884) 29 (34.524)
## 4 65-80 42 (48.837) 47 (55.952)
## 5 <NA> <NA> <NA> <NA> <NA>
## 6 Mean 75.2 <NA> 75.7 <NA>
## 7 SD 8.6 <NA> 8.3 <NA>
## 8 SE 0.9 <NA> 0.9 <NA>
## 9 Median 76.0 <NA> 77.5 <NA>
## 10 Q1 to Q3 69.25 to 81.75 <NA> 71 to 82 <NA>
## 11 Range 52 to 89 <NA> 51 to 88 <NA>
## 12 F 53 (61.628) 50 (59.524)
## 13 M 33 (38.372) 34 (40.476)
## 14 AMERICAN INDIAN OR ALASKA NATIVE 0 (0.000) 0 (0.000)
## 15 BLACK OR AFRICAN AMERICAN 8 (9.302) 6 (7.143)
## 16 WHITE 78 (90.698) 78 (92.857)
## n_3 p_3 var_label
## 1 84 <NA> -----
## 2 11 (13.095) Age (years)
## 3 18 (21.429) Age (years)
## 4 55 (65.476) Age (years)
## 5 <NA> <NA> Age (years)
## 6 74.4 <NA> Age (years)
## 7 7.9 <NA> Age (years)
## 8 0.9 <NA> Age (years)
## 9 76.0 <NA> Age (years)
## 10 70.75 to 80 <NA> Age (years)
## 11 56 to 88 <NA> Age (years)
## 12 40 (47.619) Gender
## 13 44 (52.381) Gender
## 14 1 (1.190) Race
## 15 9 (10.714) Race
## 16 74 (88.095) Race
Output as RTF
outdata |> rtf_base_char(
source = "Source: [CDISCpilot: adam-adsl]",
path_outdata = tempfile(fileext = ".Rdata"),
path_outtable = "base_char.rtf"
)
## The outdata is saved in/tmp/RtmpQFc9y0/file195a668e1637.Rdata
## The output is saved in/home/runner/work/metalite.sl/metalite.sl/vignettes/base_char.rtf
Create Treatment Compliance Table
## List of 14
## $ meta :List of 7
## $ population : chr "apat"
## $ observation : chr "apat"
## $ parameter : chr "comp8;comp16;comp24"
## $ n :'data.frame': 1 obs. of 6 variables:
## $ order : NULL
## $ group : chr "TRTA"
## $ reference_group: NULL
## $ char_n :List of 3
## $ char_var : chr [1:3] "COMP8FL" "COMP16FL" "COMP24FL"
## $ char_prop :List of 3
## $ var_type :List of 3
## $ group_label : Factor w/ 3 levels "Placebo","Low Dose",..: 1 3 2
## $ analysis : chr "trt_compliance"
## The outdata is saved in/tmp/RtmpQFc9y0/file195a570c276e.Rdata
## The output is saved in/tmp/RtmpQFc9y0/file195a3466e859.rtf
Create Treatment Compliance Table
## List of 14
## $ meta :List of 7
## $ population : chr "apat"
## $ observation : chr "apat"
## $ parameter : chr "disposition;medical-disposition"
## $ n :'data.frame': 1 obs. of 6 variables:
## $ order : NULL
## $ group : chr "TRTA"
## $ reference_group: NULL
## $ char_n :List of 2
## $ char_var : chr [1:2] "EOSSTT" "EOTSTT1"
## $ char_prop :List of 2
## $ var_type :List of 2
## $ group_label : Factor w/ 3 levels "Placebo","Low Dose",..: 1 3 2
## $ analysis : chr "disp"