---
title: LSIDEM01
subtitle: Listing of Demographics and Baseline Characteristics
---
------------------------------------------------------------------------
{{< include ../../_utils/envir_hook.qmd >}}
```{r setup, echo = FALSE, warning = FALSE, message = FALSE}
options(docx.add_datetime = FALSE, tidytlg.add_datetime = FALSE)
envsetup_config_name <- "default"
# Path to the combined config file
envsetup_file_path <- file.path("../..", "envsetup.yml")
Sys.setenv(ENVSETUP_ENVIRON = '')
library(envsetup)
loaded_config <- config::get(config = envsetup_config_name, file = envsetup_file_path)
envsetup::rprofile(loaded_config)
dpscomp <- compound
dpspdr <- paste(protocol,dbrelease,rpteff,sep="__")
aptcomp <- compound
aptpdr <- paste(protocol,dbrelease,rpteff,sep="__")
###### Study specific updates (formerly in envre)
dpscomp <- "standards"
dpspdr <- "jjcs__NULL__jjcs - core"
apt <- FALSE
library(junco)
default_str_map <- rbind(default_str_map, c("&ctcae", "5.0"))
```
## Output
:::: panel-tabset
## {{< fa regular file-lines sm fw >}} Preview
```{r variant1, results='hide', warning = FALSE, message = FALSE}
# Program Name: lsidem01.R
# Prep environment
library(envsetup)
library(tern)
library(dplyr)
library(rtables)
library(rlistings)
library(junco)
# Define script level parameters
tblid <- "LSIDEM01"
fileid <- tblid
popfl <- "FASFL"
trtvar <- "TRT01P"
key_cols <- c("COL0", "COL1")
disp_cols <- paste0("COL", 0:10)
concat_sep <- " / "
tab_titles <- get_titles_from_file(input_path = '../../_data/', tblid)
string_map <- default_str_map
# Process data
adsl <- pharmaverseadamjnj::adsl %>%
filter(!!rlang::sym(popfl) == "Y")
lsting <- adsl %>%
mutate(
AGE = explicit_na(as.character(AGE), ""),
SEX = explicit_na(SEX, ""),
RACE_DECODE = explicit_na(RACE_DECODE, ""),
COL0 = explicit_na(.data[[trtvar]], ""),
COL1 = explicit_na(USUBJID, ""),
COL2 = explicit_na(REGION1, ""),
COL3 = explicit_na(COUNTRY_DECODE, ""),
COL4 = explicit_na(toupper(format(RFICDT, "%d%b%Y")), ""),
COL5 = paste(AGE, SEX, RACE_DECODE, sep = concat_sep),
COL6 = explicit_na(ETHNIC_DECODE, ""),
COL7 = explicit_na(
tidytlg::roundSAS(WEIGHTBL, digits = 1, as_char = TRUE, na_char = ""),
""
),
COL8 = explicit_na(
tidytlg::roundSAS(HEIGHTBL, digits = 1, as_char = TRUE, na_char = ""),
""
),
COL9 = explicit_na(
tidytlg::roundSAS(BMIBL, digits = 2, as_char = TRUE, na_char = ""),
""
),
# Optional Column: COL10/BSABL
COL10 = explicit_na(
tidytlg::roundSAS(BSABL, digits = 2, as_char = TRUE, na_char = ""),
""
),
) %>%
arrange(COL0, COL1)
lsting <- var_relabel(
lsting,
COL0 = "Treatment Group",
COL1 = "Subject ID",
COL2 = "Region",
COL3 = paste("Country", "Territory", sep = concat_sep),
COL4 = "Informed Consent Date",
COL5 = paste("Age (years)", "Sex", "Race", sep = concat_sep),
COL6 = "Ethnicity",
COL7 = "Weight (kg)",
COL8 = "Height (cm)",
COL9 = "BMI (kg/m~[super 2])",
# Optional Column: COL10/BSABL
COL10 = "BSA (m~[super 2])"
)
# Build listing
result <- rlistings::as_listing(
df = lsting,
key_cols = key_cols,
disp_cols = disp_cols
)
# Add titles and footnotes
result <- set_titles(result, tab_titles)
# Output listing
tt_to_tlgrtf(string_map = string_map, tt = head(result, 100), file = fileid, orientation = "landscape")
```
```{r result1, echo=FALSE, message=FALSE, warning=FALSE, test = list(result_v1 = "result")}
tt_to_flextable_j(head(result,100), tblid, string_map = string_map)
```
[Download RTF file](`r paste0(tolower(tblid), '.rtf')`)
::::