knitr::opts_chunk$set( comment = "#>", collapse = TRUE, out.width = "100%", dpi = 150 )
library(metalite.ae)
The AE specific subgroup analysis aims to provide tables to summarize details of adverse events by subgroup. The development of AE specific subgroup analysis involves exported functions:
prepare_ae_specific_subgroup()
: prepare analysis raw datasets.format_ae_specific_subgroup()
: prepare analysis (mock) outdata with proper format.tlf_ae_specific_subgroup()
: transfer (mock) output dataset to RTF table.The prepare_ae_specific_subgroup()
function is designed to be used for multiple purposes.
The input of the function is a meta
object created by the metalite package.
meta <- meta_ae_example()
The output of the function is an outdata
object containing a list of analysis
raw datasets. Key arguments are subgroup_var
, subgroup_header
, and
display_subgroup_total
.
outdata <- prepare_ae_specific_subgroup( meta, population = "apat", observation = "wk12", parameter = "rel", subgroup_var = "SEX", subgroup_header = c("TRTA", "SEX"), display_subgroup_total = TRUE )
outdata
The output dataset contains commonly used statistics within each subgroup_var
.
outdata$out_all$F outdata$out_all$M outdata$out_all$Total
The variable is indexed by the order of outdata$group
and outdata$subgroup
within each subgroup_var
.
outdata$group outdata$subgroup
The row is indexed by the order of name
within each subgroup_var
analysis output.
head(data.frame(outdata$out_all$Total$order, outdata$out_all$Total$name))
n_pop
: participants in population within each subgroup_var
.outdata$out_all$F$n_pop outdata$out_all$M$n_pop outdata$out_all$Total$n_pop
n
: number of subjects with AE within each subgroup_var
.head(outdata$out_all$F$n) head(outdata$out_all$M$n) head(outdata$out_all$Total$n)
prop
: proportion of subjects with AE within each subgroup_var
.head(outdata$out_all$F$prop) head(outdata$out_all$M$prop) head(outdata$out_all$Total$prop)
diff
: risk difference compared with the reference_group
within each subgroup_var
.head(outdata$out_all$Total$diff)
After we have the raw analysis results, we can use format_ae_specific_subgroup()
to prepare the outdata to create RTF tables.
tbl <- outdata |> format_ae_specific_subgroup() head(tbl$tbl)
We can hide the total column:
tbl <- outdata |> format_ae_specific_subgroup(display = c("n", "prop")) head(tbl$tbl)
Adding risk difference:
tbl <- outdata |> format_ae_specific_subgroup(display = c("n", "prop", "diff")) head(tbl$tbl)
We can also use format_ae_specific_subgroup()
to create mock output data.
The purpose of the mock
argument is not to create a comprehensive mock table template,
but a handy way to help users create a mock table that mimics the exact output layout.
Additional work is required to develop a flexible mock table generation tool (for example, a dedicated mock table generation package).
tbl <- outdata |> format_ae_specific_subgroup(mock = FALSE) head(tbl$tbl)
By using tlf_ae_specific_subgroup()
, we can transfer the output from
format_ae_specific_subgroup()
to an RTF or PDF table.
outdata |> format_ae_specific_subgroup() |> tlf_ae_specific_subgroup( meddra_version = "24.0", source = "Source: [CDISCpilot: adam-adsl; adae]", analysis = "ae_specific", # Provide analysis type defined in meta$analysis path_outtable = "rtf/ae0specific0sub0gender1.rtf" )
knitr::include_graphics("pdf/ae0specific0sub0gender1.pdf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.