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 Baseline
A: Drug X 14/134 (10.4%) 8/134 (6.0%)
B: Placebo 11/134 (8.2%) 11/134 (8.2%)
C: Combination 15/132 (11.4%) 14/132 (10.6%)
ALT>3x Baseline
A: Drug X 7/134 (5.2%) 20/134 (14.9%)
B: Placebo 10/134 (7.5%) 9/134 (6.7%)
C: Combination 12/132 (9.1%) 8/132 (6.1%)
AST>3x Baseline or ALT>3x Baseline
A: Drug X 8/134 (6.0%) 22/134 (16.4%)
B: Placebo 19/134 (14.2%) 15/134 (11.2%)
C: Combination 14/132 (10.6%) 13/132 (9.8%)
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("ASTPBASE", "ALTPBASE", "ALTASTPB") & 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 =="ASTPBASE"~"AST>3x Baseline", PARAMCD =="ALTPBASE"~"ALT>3x Baseline", PARAMCD =="ALTASTPB"~"AST>3x Baseline or ALT>3x Baseline" ),levels =c("AST>3x Baseline", "ALT>3x Baseline", "AST>3x Baseline or ALT>3x Baseline") ),TITLE =factor("First Elevated Result Occurring During") )anl <-df_explicit_na(anl)