Introduction
This article describes creating reports which can be classified as
ADSL Summary Tables using adsl_summary
function. Example
here is created using ADSL
domain.
Note: All examples assume CDISC ADaM format as input unless otherwise specified.
Programming Flow
Preprocess Data
Before creating adsl_summary
, it is required to use the
pre-processing function: mentry
which serves as an
essential step in preparing the data for summarisation.
mentry()
The next step in pre-processing involves the usage of
mentry
function to read and process data with subsets and
variables. It takes in the adsl
as input . The input data
gets processed based on TRT
(mandatory variable for
generating columns in the final table), BY
(optional
variable used to group rows in the final table) and/or
SUBGROUP
(optional variable used to add subgroups under the
columns-TRT in the final table) variables and filtered by subset
conditions.
Note: For additional information such as parameters info, refer to the mentry() documentation.
mentry_df <- adsl |>
mentry(
subset = NA_character_,
byvar = NA_character_,
trtvar = "TRT01A",
trtsort = "TRT01AN",
subgrpvar = NA_character_,
trttotalyn = "Y",
add_grpmiss = "N",
pop_fil = "SAFFL"
)
ADSL Summary Table
This step is used in creating the ADSL summary table using the ‘adsl_summary’ function.
The following are the arguments for the table:
-
datain
: The input data for table generation. The output data frommentry_df
function. -
vars
: Names ofadsl
variables to display in final output which are tilde-separated, Add"-S"
for numeric variables. -
stat_vars
: Statistics to display in table for numeric vars, tilde-separated. -
pctdisp
: Denominator to calculate percentages by. Values:"TRT", "VAR", "COL", "SUBGRP", "SGRPN", "CAT", "NONE", "NO", "DPTVAR"
. -
total_catyn
To return a ‘Total’ row for categorical analysis invars
. Values:"Y"/"N"
-
total_catlabel
Label for total category row. eg- “All”/“Total” -
miss_catyn
To include empty/blank values asmiss_catlabel
in categories ofdptvar
variable or not. Values:"Y"/"N"
-
miss_catlabel
Label for missing values -
a_subset
Analysis Subset condition; tilde-separated for each variable invars
. -
denom_subset
Subset condition to be applied to dataset for calculating denominator, tilde-separated for categorical variables withinvars
.
adsl_sum <- mentry_df |>
adsl_summary(
vars = "AGEGR1/AGEGR1N~AGE-S~SEX/SEXN~RACE/RACEN",
stat_vars = "N~Range~Meansd~Median~IQR",
pctdisp = "TRT",
total_catyn = "N",
total_catlabel = "Total",
miss_catyn = "N",
miss_catlabel = "Missing",
a_subset = "AGE<65~AGE>80~SEX=='F'~NA",
denom_subset = NA_character_
)
ADSL Table Display
Prepare data for general table display
This step is used creating the ADSL summary table using ‘tbl_processor’ function to prepare data for general table display.
The following are the arguments:
-
datain
Input dataframe. The output data fromadsl_summary
function. -
dptlabel
Tilde-separated labels to set to category variables in data. If analysis vars (DPTVAR
) containsAGEGR1, RACE
;dptlabel
may be"Age Group~Race"
. -
statlabel
Tilde-separated labels corresponding to each Statistic in data. -
extra_df
Additional dataframe, to merge withdatain
. -
extra_mergeby
Variables to mergeextra_df
by, if present. -
dropvars
Variables additional to standard present in input data to be removed from output -
disp_value_col
Hide/Show value column from the final display. -
addrowvars
Group Variable(s) to be removed as a column and instead used as row headers in the value column.
Create flextable output from display templates
This step is used creating the ADSL summary table using ‘tbl_display’ to create flextable output from display templates.
The following are the arguments:
-
datain
Input dataframe. The output data fromtbl_processor
function. -
bylabel
ChangeBYVAR
names to label, if any. -
dpthead
String to become name of the column containing categories (DPTVAL
) in output. -
font
Font face for text inside table -
fontsize
Font size for text inside table
ADSL Table Display Output
The ADSL Summary Table is generated successfully. Below is the Table generated:
adsl_sum |>
display_bign_head(mentry_data = mentry_df) |>
tbl_processor(
statlabel = "N~Range~Meansd~Median~IQR",
dptlabel = "Age Group~NONE~Sex~Race",
addrowvar = "DPTVAR"
) |>
tbl_display() |>
flextable::autofit()
|
Placebo (N=86) |
Xanomeline Low Dose (N=84) |
Xanomeline High Dose (N=84) |
Total (N=254) |
---|---|---|---|---|
Age Group |
||||
<65 |
14 (16.28%) |
8 ( 9.52%) |
11 (13.10%) |
33 (12.99%) |
NONE |
||||
N |
30 |
29 |
18 |
77 |
Range |
_NO_STAT |
_NO_STAT |
_NO_STAT |
_NO_STAT |
Meansd |
_NO_STAT |
_NO_STAT |
_NO_STAT |
_NO_STAT |
Median |
84.00 |
83.00 |
83.50 |
84.00 |
IQR |
4.75 |
2.00 |
2.75 |
3.00 |
Sex |
||||
F |
53 (61.63%) |
50 (59.52%) |
40 (47.62%) |
143 (56.30%) |
Race |
||||
WHITE |
78 (90.70%) |
78 (92.86%) |
74 (88.10%) |
230 (90.55%) |
BLACK OR AFRICAN AMERICAN |
8 ( 9.30%) |
6 ( 7.14%) |
9 (10.71%) |
23 ( 9.06%) |
AMERICAN INDIAN OR ALASKA NATIVE |
0 |
0 |
1 ( 1.19%) |
1 ( 0.39%) |