result <-basic_table() %>%split_cols_by("TITLE") %>%split_cols_by("APERIODC") %>%split_rows_by("PARAM") %>%split_rows_by("ACTARM", split_fun = drop_split_levels, child_labels ="hidden") %>%count_occurrences("ARM_AVALC", .stats ="fraction", denom ="n", drop =TRUE) %>%build_table(anl)criteria_fun <-function(tr) { row_label <-obj_label(tr) dplyr::if_else(row_label =="Criteria not met", TRUE, FALSE)}result <- result %>%trim_rows(criteria = criteria_fun)result
First Elevated Result Occurring During
PERIOD 1 PERIOD 2
——————————————————————————————————————————————————————————————————————
AST >3x ULN
A: Drug X 11/134 (8.2%) 21/134 (15.7%)
B: Placebo 17/134 (12.7%) 16/134 (11.9%)
C: Combination 10/132 (7.6%) 8/132 (6.1%)
ALT >3x ULN
A: Drug X 14/134 (10.4%) 8/134 (6.0%)
B: Placebo 24/134 (17.9%) 18/134 (13.4%)
C: Combination 16/132 (12.1%) 10/132 (7.6%)
AST >3x ULN or ALT >x3 ULN
A: Drug X 14/134 (10.4%) 15/134 (11.2%)
B: Placebo 8/134 (6.0%) 13/134 (9.7%)
C: Combination 11/132 (8.3%) 12/132 (9.1%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
Code
library(dplyr)library(tern)adhy <- random.cdisc.data::cadhyanl <- adhyanl$APERIODC <-as.factor(anl$APERIODC) # to ensure the table is built even if there is no patients after filteringanl$ACTARM <-as.factor(anl$ACTARM) # to ensure the table is built even if there is no patients after filteringanl <- anl %>%filter( SAFFL =="Y", PARAMCD %in%c("ASTPULN", "ALTPULN", "ALTASTPU") & AVISIT =="POST-BASELINE" ) %>%mutate(ARM_AVALC =factor(case_when( AVALC =="Y"~as.character(ACTARM),TRUE~"Criteria not met" ),levels =c(levels(anl$ACTARM), "Criteria not met") ),PARAM =factor(case_when( PARAMCD =="ASTPULN"~"AST >3x ULN", PARAMCD =="ALTPULN"~"ALT >3x ULN", PARAMCD =="ALTASTPU"~"AST >3x ULN or ALT >x3 ULN" ),levels =c("AST >3x ULN", "ALT >3x ULN", "AST >3x ULN or ALT >x3 ULN") ),TITLE =factor("First Elevated Result Occurring During") )anl <-df_explicit_na(anl)