---
title: LBT12
subtitle: Liver Laboratory Tests by Time on Treatment -- Patients with Elevated Post-Baseline AST or ALT Levels (with Respect to ULN)
---
------------------------------------------------------------------------
{{< include ../../_utils/envir_hook.qmd >}}
```{r setup, echo = FALSE, warning = FALSE, message = FALSE}
library(dplyr)
library(tern)
adhy <- random.cdisc.data::cadhy
anl <- adhy
anl$APERIODC <- as.factor(anl$APERIODC) # to ensure the table is built even if there is no patients after filtering
anl$ACTARM <- as.factor(anl$ACTARM) # to ensure the table is built even if there is no patients after filtering
anl <- 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)
```
```{r include = FALSE}
webr_code_labels <- c("setup")
```
{{< include ../../_utils/webr_no_include.qmd >}}
## Output
:::: panel-tabset
## Standard Table
::: {.panel-tabset .nav-justified group="webr"}
## {{< fa regular file-lines sm fw >}} Preview
```{r variant1, test = list(result_v1 = "result")}
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
```
```{r include = FALSE}
webr_code_labels <- c("variant1")
```
{{< include ../../_utils/webr.qmd >}}
:::
## Data Setup
```{r setup}
#| code-fold: show
```
::::
{{< include ../../_utils/save_results.qmd >}}
{{< include ../../repro.qmd >}}