TL Catalog
  1. Tables
  2. Disposition of Subjects
  3. TSIDS02A
  • Introduction

  • Index

  • Tables
    • Adverse Events
      • TSFAE01A
      • TSFAE01B
      • TSFAE02
      • TSFAE02A
      • TSFAE03
      • TSFAE03A
      • TSFAE04
      • TSFAE04A
      • TSFAE05
      • TSFAE05A
      • TSFAE06A
      • TSFAE06B
      • TSFAE07A
      • TSFAE07B
      • TSFAE08
      • TSFAE09
      • TSFAE10
      • TSFAE11
      • TSFAE12
      • TSFAE13
      • TSFAE14
      • TSFAE15
      • TSFAE16
      • TSFAE17A
      • TSFAE17B
      • TSFAE17C
      • TSFAE17D
      • TSFAE19A
      • TSFAE19B
      • TSFAE19C
      • TSFAE19D
      • TSFAE20A
      • TSFAE20B
      • TSFAE20C
      • TSFAE21A
      • TSFAE21B
      • TSFAE21C
      • TSFAE21D
      • TSFAE22A
      • TSFAE22B
      • TSFAE22C
      • TSFAE23A
      • TSFAE23B
      • TSFAE23C
      • TSFAE23D
      • TSFAE24A
      • TSFAE24B
      • TSFAE24C
      • TSFAE24D
      • TSFAE24F
      • TSFDTH01
    • Clinical Laboratory Evaluation
      • TSFLAB01
      • TSFLAB01A
      • TSFLAB02
      • TSFLAB02A
      • TSFLAB02B
      • TSFLAB03
      • TSFLAB03A
      • TSFLAB04A
      • TSFLAB04B
      • TSFLAB05
      • TSFLAB06
      • TSFLAB07
    • Demographic
      • TSIDEM01
      • TSIDEM02
      • TSIMH01
    • Disposition of Subjects
      • TSIDS01
      • TSIDS02
      • TSIDS02A
    • Electrocardiograms
      • TSFECG01
      • TSFECG01A
      • TSFECG02
      • TSFECG03
      • TSFECG04
      • TSFECG05
    • Exposure
      • TSIEX01
      • TSIEX02
      • TSIEX03
      • TSIEX04
      • TSIEX06
      • TSIEX07
      • TSIEX08
      • TSIEX09
      • TSIEX10
      • TSIEX11
    • Pharmacokinetics
      • TPK01A
      • TPK01B
      • TPK02
      • TPK03
    • Prior and Concomitant Therapies
      • TSICM01
      • TSICM02
      • TSICM03
      • TSICM04
      • TSICM05
      • TSICM06
      • TSICM07
      • TSICM08
    • Vital Signs and Physical Findings
      • TSFVIT01
      • TSFVIT01A
      • TSFVIT02
      • TSFVIT03
      • TSFVIT04
      • TSFVIT05
      • TSFVIT06
  • Listings
    • Adverse Events
      • LSFAE01
      • LSFAE02
      • LSFAE03
      • LSFAE04
      • LSFAE05
      • LSFAE06A
      • LSFAE06B
      • LSFDTH01
    • Clinical Laboratory Evaluation
      • LSFLAB01
    • Demographic
      • LSIDEM01
      • LSIDEM02
      • LSIMH01
    • Disposition of Subjects
      • LSIDS01
      • LSIDS02
      • LSIDS03
      • LSIDS04
      • LSIDS05
    • Electrocardiograms
      • LSFECG01
      • LSFECG02
    • Exposure
      • LSIEX01
      • LSIEX02
      • LSIEX03
    • Prior and Concomitant Therapies
      • LSICM01
    • Vital Signs and Physical Findings
      • LSFVIT01
      • LSFVIT02

  • Reproducibility

  • Changelog

On this page

  • Output
  • Edit this page
  • Report an issue
  1. Tables
  2. Disposition of Subjects
  3. TSIDS02A

TSIDS02A

Subject Disposition by Subgroup


Output

  • Preview
Code
# Program Name:              tsids02a

# Prep environment:

library(envsetup)
library(tern)
library(dplyr)
library(rtables)
library(junco)

# Define output ID and file location:

tblid <- "TSIDS02a"
fileid <- tblid
popfl <- "FASFL"
trtvar <- "TRT01P"
tab_titles <- get_titles_from_file(input_path = '../../_data/', tblid)
string_map <- default_str_map

# Process data:

adsl <- pharmaverseadamjnj::adsl

no_data_to_report <- function(df, var) {
  if (sum(is.na(df[[var]])) == length(df[[var]])) {
    df[[var]] <- factor(NA_character_, levels = "No data to report")
  }
  return(df)
}

adsl <- no_data_to_report(df = adsl, var = "DCTREAS")
adsl <- no_data_to_report(df = adsl, var = "DCSREAS")

adsl <- adsl %>%
  filter(!!rlang::sym(popfl) == "Y") %>%
  select(
    USUBJID,
    !!rlang::sym(trtvar),
    !!rlang::sym(popfl),
    SAFFL,
    PPROTFL,
    EOTSTT,
    DCTREAS,
    EOSSTT,
    DCSREAS,
    RACE_DECODE
  ) %>%
  create_colspan_var(
    non_active_grp = "Placebo",
    non_active_grp_span_lbl = " ",
    active_grp_span_lbl = "Active Study Agent",
    colspan_var = "colspan_trt",
    trt_var = trtvar
  ) %>%
  mutate(
    rrisk_header = "Risk Difference (%) 95% CI",
    rrisk_label = paste(!!rlang::sym(trtvar), "vs Placebo")
  )

# Added since label_fstr not working with cpct_relrisk
adsl$RACE <- as.factor(as.character(ifelse(
  is.na(adsl$RACE_DECODE),
  NA,
  paste("Race:", adsl$RACE_DECODE)
)))

colspan_trt_map <- create_colspan_map(
  adsl,
  non_active_grp = "Placebo",
  non_active_grp_span_lbl = " ",
  active_grp_span_lbl = "Active Study Agent",
  colspan_var = "colspan_trt",
  trt_var = trtvar
)
ref_path <- c("colspan_trt", " ", trtvar, "Placebo")

# Define layout and build table:

totdf <- tribble(
  ~valname , ~label  , ~levelcombo                                                 , ~exargs ,
  "Total"  , "Total" , c("Xanomeline High Dose", "Xanomeline Low Dose", "Placebo") , list()
)


extra_args1 <- list(
  denom = "n_altdf",
  denom_by = "RACE",
  riskdiff = FALSE,
  .stats = "count_unique"
)
extra_args2 <- list(
  denom = "n_altdf",
  denom_by = "RACE",
  riskdiff = FALSE,
  .stats = "count_unique_fraction"
)
extra_args3 <- list(
  denom = "n_altdf",
  denom_by = "RACE",
  riskdiff = TRUE,
  method = "wald",
  .stats = "count_unique_fraction",
  ref_path = ref_path
)


lyt <- basic_table(
  show_colcounts = TRUE,
  colcount_format = "N=xx",
  top_level_section_div = " "
) %>%
  split_cols_by(
    "colspan_trt",
    split_fun = trim_levels_to_map(map = colspan_trt_map)
  ) %>%
  split_cols_by(trtvar) %>%
  split_cols_by(
    trtvar,
    split_fun = add_combo_levels(totdf, keep_levels = "Total"),
    nested = FALSE
  ) %>%
  split_cols_by("rrisk_header", nested = FALSE) %>%
  split_cols_by(
    trtvar,
    labels_var = "rrisk_label",
    split_fun = remove_split_levels("Placebo")
  ) %>%
  split_rows_by("RACE", split_fun = drop_split_levels, section_div = " ") %>%
  summarize_row_groups(
    "RACE",
    cfun = a_freq_j,
    indent_mod = 0L,
    # na_str = " ",
    extra_args = extra_args1
  ) %>%
  # Analysis sets
  analyze(
    popfl,
    var_labels = "Analysis set:",
    afun = a_freq_j,
    extra_args = append(extra_args2, list(label = "Full", val = "Y")),
    show_labels = "visible"
  ) %>%
  analyze(
    "SAFFL",
    afun = a_freq_j,
    extra_args = append(extra_args2, list(label = "Safety", val = "Y")),
    show_labels = "hidden",
    indent_mod = 1
  ) %>%
  analyze(
    "PPROTFL",
    afun = a_freq_j,
    extra_args = append(
      extra_args2,
      list(label = "Per protocol", val = "Y", extrablankline = TRUE)
    ),
    show_labels = "hidden",
    indent_mod = 1,
    na_str = " "
  ) %>%
  #  Ongoing
  analyze(
    "EOSSTT",
    show_labels = "hidden",
    afun = a_freq_j,
    na_str = " ",
    extra_args = append(
      extra_args2,
      list(val = "ONGOING", label = "Subjects ongoing", extrablankline = TRUE)
    )
  ) %>%
  # Treatment disposition
  analyze(
    "EOTSTT",
    table_names = "Compl_Trt",
    show_labels = "hidden",
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(label = "Completed treatment", val = "COMPLETED")
    )
  ) %>%
  analyze(
    "EOTSTT",
    table_names = "DC_Trt",
    show_labels = "hidden",
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(label = "Discontinued treatment", val = "DISCONTINUED")
    )
  ) %>%
  analyze(
    "DCTREAS",
    show_labels = "hidden",
    indent_mod = 1,
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(extrablankline = TRUE, drop_levels = TRUE)
    )
  ) %>%
  # Study disposition
  analyze(
    "EOSSTT",
    table_names = "Compl_Study",
    show_labels = "hidden",
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(label = "Completed study", val = "COMPLETED")
    )
  ) %>%
  analyze(
    "EOSSTT",
    show_labels = "hidden",
    table_names = "DC_Study",
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(label = "Discontinued study", val = "DISCONTINUED")
    )
  ) %>%
  analyze(
    "DCSREAS",
    show_labels = "hidden",
    indent_mod = 1,
    afun = a_freq_j,
    extra_args = append(extra_args3, list(drop_levels = TRUE))
  )

result <- build_table(lyt, adsl, alt_counts_df = adsl)

# Post-Processing

# Remove the N=xx column headers for the risk difference columns
result <- remove_col_count(result, span_label_var = "rrisk_header")

# Sort DCTREAS and DCSREAD by descending total column.
result <- result %>%
  sort_at_path(
    path = c("RACE", "*", "DCTREAS"),
    scorefun = jj_complex_scorefun(colpath = "Total", lastcat = "Other")
  ) %>%
  sort_at_path(
    path = c("RACE", "*", "DCSREAS"),
    scorefun = jj_complex_scorefun(colpath = "Total")
  )

result <- prune_table(
  result,
  prune_func = remove_rows(removerowtext = "No data to report")
)

# Add titles and footnotes:

result <- set_titles(result, tab_titles)

# Convert to tbl file and output table:

tt_to_tlgrtf(string_map = string_map, tt = result, file = fileid, orientation = "landscape")

TSIDS02a: Subject Disposition by [Subgroup]; [Randomized/Enrolled] Analysis Set (Study jjcs - core)

Active Study Agent

Risk Difference (%) 95% CI

Xanomeline High Dose

Xanomeline Low Dose

Placebo

Total

Xanomeline High Dose vs Placebo

Xanomeline Low Dose vs Placebo

N=84

N=84

N=86

N=254

Race: American Indian or Alaska
 Native

7

13

6

26

Analysis set:

Full

7 (100.0%)

13 (100.0%)

6 (100.0%)

26 (100.0%)

Safety

5 (71.4%)

10 (76.9%)

3 (50.0%)

18 (69.2%)

Per protocol

5 (71.4%)

10 (76.9%)

3 (50.0%)

18 (69.2%)

Subjects ongoing

2 (28.6%)

0

0

2 (7.7%)

Completed treatment

1 (14.3%)

3 (23.1%)

3 (50.0%)

7 (26.9%)

-35.7 (-83.4, 12.0)

-26.9 (-73.0, 19.2)

Discontinued treatment

5 (71.4%)

7 (53.8%)

1 (16.7%)

13 (50.0%)

54.8 (9.9, 99.6)

37.2 (-3.1, 77.5)

Other

5 (71.4%)

7 (53.8%)

1 (16.7%)

13 (50.0%)

54.8 (9.9, 99.6)

37.2 (-3.1, 77.5)

Completed study

2 (28.6%)

3 (23.1%)

4 (66.7%)

9 (34.6%)

-38.1 (-88.5, 12.3)

-43.6 (-87.7, 0.5)

Discontinued study

3 (42.9%)

10 (76.9%)

2 (33.3%)

15 (57.7%)

9.5 (-43.1, 62.1)

43.6 (-0.5, 87.7)

Other

3 (42.9%)

10 (76.9%)

2 (33.3%)

15 (57.7%)

9.5 (-43.1, 62.1)

43.6 (-0.5, 87.7)

Race: Asian

11

11

7

29

Analysis set:

Full

11 (100.0%)

11 (100.0%)

7 (100.0%)

29 (100.0%)

Safety

11 (100.0%)

8 (72.7%)

5 (71.4%)

24 (82.8%)

Per protocol

11 (100.0%)

8 (72.7%)

5 (71.4%)

24 (82.8%)

Subjects ongoing

1 (9.1%)

2 (18.2%)

2 (28.6%)

5 (17.2%)

Completed treatment

3 (27.3%)

4 (36.4%)

2 (28.6%)

9 (31.0%)

-1.3 (-43.9, 41.3)

7.8 (-36.1, 51.7)

Discontinued treatment

7 (63.6%)

6 (54.5%)

3 (42.9%)

16 (55.2%)

20.8 (-25.6, 67.2)

11.7 (-35.3, 58.7)

Other

7 (63.6%)

6 (54.5%)

3 (42.9%)

16 (55.2%)

20.8 (-25.6, 67.2)

11.7 (-35.3, 58.7)

Completed study

3 (27.3%)

3 (27.3%)

2 (28.6%)

8 (27.6%)

-1.3 (-43.9, 41.3)

-1.3 (-43.9, 41.3)

Discontinued study

7 (63.6%)

6 (54.5%)

3 (42.9%)

16 (55.2%)

20.8 (-25.6, 67.2)

11.7 (-35.3, 58.7)

Other

7 (63.6%)

6 (54.5%)

3 (42.9%)

16 (55.2%)

20.8 (-25.6, 67.2)

11.7 (-35.3, 58.7)

Race: Black or African American

7

10

10

27

Analysis set:

Full

7 (100.0%)

10 (100.0%)

10 (100.0%)

27 (100.0%)

Safety

5 (71.4%)

9 (90.0%)

7 (70.0%)

21 (77.8%)

Per protocol

5 (71.4%)

9 (90.0%)

7 (70.0%)

21 (77.8%)

Subjects ongoing

4 (57.1%)

0

3 (30.0%)

7 (25.9%)

Completed treatment

2 (28.6%)

2 (20.0%)

6 (60.0%)

10 (37.0%)

-31.4 (-76.6, 13.8)

-40.0 (-79.2, -0.8)

Discontinued treatment

4 (57.1%)

6 (60.0%)

3 (30.0%)

13 (48.1%)

27.1 (-19.2, 73.5)

30.0 (-11.6, 71.6)

Other

4 (57.1%)

6 (60.0%)

3 (30.0%)

13 (48.1%)

27.1 (-19.2, 73.5)

30.0 (-11.6, 71.6)

Completed study

2 (28.6%)

3 (30.0%)

3 (30.0%)

8 (29.6%)

-1.4 (-45.3, 42.5)

0.0 (-40.2, 40.2)

Discontinued study

1 (14.3%)

7 (70.0%)

4 (40.0%)

12 (44.4%)

-25.7 (-65.6, 14.2)

30.0 (-11.6, 71.6)

Other

1 (14.3%)

7 (70.0%)

4 (40.0%)

12 (44.4%)

-25.7 (-65.6, 14.2)

30.0 (-11.6, 71.6)

Race: Multiple

12

9

8

29

Analysis set:

Full

12 (100.0%)

9 (100.0%)

8 (100.0%)

29 (100.0%)

Safety

11 (91.7%)

7 (77.8%)

5 (62.5%)

23 (79.3%)

Per protocol

11 (91.7%)

7 (77.8%)

5 (62.5%)

23 (79.3%)

Subjects ongoing

2 (16.7%)

3 (33.3%)

1 (12.5%)

6 (20.7%)

Completed treatment

2 (16.7%)

3 (33.3%)

4 (50.0%)

9 (31.0%)

-33.3 (-73.9, 7.2)

-16.7 (-63.0, 29.7)

Discontinued treatment

7 (58.3%)

3 (33.3%)

2 (25.0%)

12 (41.4%)

33.3 (-7.6, 74.3)

8.3 (-34.7, 51.3)

Other

7 (58.3%)

3 (33.3%)

2 (25.0%)

12 (41.4%)

33.3 (-7.6, 74.3)

8.3 (-34.7, 51.3)

Completed study

4 (33.3%)

3 (33.3%)

4 (50.0%)

11 (37.9%)

-16.7 (-60.4, 27.1)

-16.7 (-63.0, 29.7)

Discontinued study

6 (50.0%)

3 (33.3%)

3 (37.5%)

12 (41.4%)

12.5 (-31.4, 56.4)

-4.2 (-49.7, 41.4)

Other

6 (50.0%)

3 (33.3%)

3 (37.5%)

12 (41.4%)

12.5 (-31.4, 56.4)

-4.2 (-49.7, 41.4)

Race: Native Hawaiian or other
 Pacific Islander

10

7

8

25

Analysis set:

Full

10 (100.0%)

7 (100.0%)

8 (100.0%)

25 (100.0%)

Safety

8 (80.0%)

4 (57.1%)

5 (62.5%)

17 (68.0%)

Per protocol

8 (80.0%)

4 (57.1%)

5 (62.5%)

17 (68.0%)

Subjects ongoing

3 (30.0%)

1 (14.3%)

2 (25.0%)

6 (24.0%)

Completed treatment

1 (10.0%)

1 (14.3%)

4 (50.0%)

6 (24.0%)

-40.0 (-79.3, -0.7)

-35.7 (-79.0, 7.6)

Discontinued treatment

6 (60.0%)

5 (71.4%)

3 (37.5%)

14 (56.0%)

22.5 (-22.7, 67.7)

33.9 (-13.5, 81.3)

Other

6 (60.0%)

5 (71.4%)

3 (37.5%)

14 (56.0%)

22.5 (-22.7, 67.7)

33.9 (-13.5, 81.3)

Completed study

2 (20.0%)

1 (14.3%)

3 (37.5%)

6 (24.0%)

-17.5 (-59.2, 24.2)

-23.2 (-65.6, 19.2)

Discontinued study

5 (50.0%)

5 (71.4%)

3 (37.5%)

13 (52.0%)

12.5 (-33.2, 58.2)

33.9 (-13.5, 81.3)

Other

5 (50.0%)

5 (71.4%)

3 (37.5%)

13 (52.0%)

12.5 (-33.2, 58.2)

33.9 (-13.5, 81.3)

Race: Not reported

11

7

11

29

Analysis set:

Full

11 (100.0%)

7 (100.0%)

11 (100.0%)

29 (100.0%)

Safety

7 (63.6%)

5 (71.4%)

9 (81.8%)

21 (72.4%)

Per protocol

7 (63.6%)

5 (71.4%)

9 (81.8%)

21 (72.4%)

Subjects ongoing

2 (18.2%)

1 (14.3%)

2 (18.2%)

5 (17.2%)

Completed treatment

3 (27.3%)

1 (14.3%)

6 (54.5%)

10 (34.5%)

-27.3 (-66.8, 12.2)

-40.3 (-79.5, -1.0)

Discontinued treatment

7 (63.6%)

3 (42.9%)

2 (18.2%)

12 (41.4%)

45.5 (9.0, 81.9)

24.7 (-18.5, 67.8)

Other

7 (63.6%)

3 (42.9%)

2 (18.2%)

12 (41.4%)

45.5 (9.0, 81.9)

24.7 (-18.5, 67.8)

Completed study

2 (18.2%)

2 (28.6%)

7 (63.6%)

11 (37.9%)

-45.5 (-81.9, -9.0)

-35.1 (-79.0, 8.8)

Discontinued study

7 (63.6%)

4 (57.1%)

2 (18.2%)

13 (44.8%)

45.5 (9.0, 81.9)

39.0 (-4.2, 82.1)

Other

7 (63.6%)

4 (57.1%)

2 (18.2%)

13 (44.8%)

45.5 (9.0, 81.9)

39.0 (-4.2, 82.1)

Race: Other

5

11

16

32

Analysis set:

Full

5 (100.0%)

11 (100.0%)

16 (100.0%)

32 (100.0%)

Safety

1 (20.0%)

8 (72.7%)

10 (62.5%)

19 (59.4%)

Per protocol

1 (20.0%)

8 (72.7%)

10 (62.5%)

19 (59.4%)

Subjects ongoing

1 (20.0%)

2 (18.2%)

1 (6.2%)

4 (12.5%)

Completed treatment

3 (60.0%)

4 (36.4%)

8 (50.0%)

15 (46.9%)

10.0 (-39.4, 59.4)

-13.6 (-51.2, 23.9)

Discontinued treatment

2 (40.0%)

5 (45.5%)

5 (31.2%)

12 (37.5%)

8.8 (-39.8, 57.3)

14.2 (-23.0, 51.4)

Other

2 (40.0%)

5 (45.5%)

5 (31.2%)

12 (37.5%)

8.8 (-39.8, 57.3)

14.2 (-23.0, 51.4)

Completed study

2 (40.0%)

4 (36.4%)

10 (62.5%)

16 (50.0%)

-22.5 (-71.6, 26.6)

-26.1 (-63.2, 10.9)

Discontinued study

2 (40.0%)

5 (45.5%)

5 (31.2%)

12 (37.5%)

8.8 (-39.8, 57.3)

14.2 (-23.0, 51.4)

Other

2 (40.0%)

5 (45.5%)

5 (31.2%)

12 (37.5%)

8.8 (-39.8, 57.3)

14.2 (-23.0, 51.4)

Race: Unknown

10

6

11

27

Analysis set:

Full

10 (100.0%)

6 (100.0%)

11 (100.0%)

27 (100.0%)

Safety

7 (70.0%)

4 (66.7%)

8 (72.7%)

19 (70.4%)

Per protocol

7 (70.0%)

4 (66.7%)

8 (72.7%)

19 (70.4%)

Subjects ongoing

0

3 (50.0%)

1 (9.1%)

4 (14.8%)

Completed treatment

2 (20.0%)

2 (33.3%)

9 (81.8%)

13 (48.1%)

-61.8 (-95.5, -28.1)

-48.5 (-92.6, -4.4)

Discontinued treatment

6 (60.0%)

1 (16.7%)

2 (18.2%)

9 (33.3%)

41.8 (3.9, 79.8)

-1.5 (-39.0, 36.0)

Other

6 (60.0%)

1 (16.7%)

2 (18.2%)

9 (33.3%)

41.8 (3.9, 79.8)

-1.5 (-39.0, 36.0)

Completed study

3 (30.0%)

2 (33.3%)

8 (72.7%)

13 (48.1%)

-42.7 (-81.4, -4.0)

-39.4 (-85.4, 6.6)

Discontinued study

7 (70.0%)

1 (16.7%)

2 (18.2%)

10 (37.0%)

51.8 (15.4, 88.2)

-1.5 (-39.0, 36.0)

Other

7 (70.0%)

1 (16.7%)

2 (18.2%)

10 (37.0%)

51.8 (15.4, 88.2)

-1.5 (-39.0, 36.0)

Race: White

11

10

9

30

Analysis set:

Full

11 (100.0%)

10 (100.0%)

9 (100.0%)

30 (100.0%)

Safety

9 (81.8%)

7 (70.0%)

7 (77.8%)

23 (76.7%)

Per protocol

9 (81.8%)

7 (70.0%)

7 (77.8%)

23 (76.7%)

Subjects ongoing

3 (27.3%)

3 (30.0%)

2 (22.2%)

8 (26.7%)

Completed treatment

2 (18.2%)

1 (10.0%)

7 (77.8%)

10 (33.3%)

-59.6 (-95.1, -24.1)

-67.8 (-100.0, -34.9)

Discontinued treatment

5 (45.5%)

7 (70.0%)

1 (11.1%)

13 (43.3%)

34.3 (-1.5, 70.2)

58.9 (23.8, 93.9)

Other

5 (45.5%)

7 (70.0%)

1 (11.1%)

13 (43.3%)

34.3 (-1.5, 70.2)

58.9 (23.8, 93.9)

Completed study

2 (18.2%)

0

7 (77.8%)

9 (30.0%)

-59.6 (-95.1, -24.1)

-77.8 (-100.0, -50.6)

Discontinued study

6 (54.5%)

7 (70.0%)

0

13 (43.3%)

54.5 (25.1, 84.0)

70.0 (41.6, 98.4)

Other

6 (54.5%)

7 (70.0%)

0

13 (43.3%)

54.5 (25.1, 84.0)

70.0 (41.6, 98.4)

Download RTF file

TSIDS02
TSFECG01
Source Code
---
title: TSIDS02A
subtitle: Subject Disposition by Subgroup
---

------------------------------------------------------------------------

{{< 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:              tsids02a

# Prep environment:

library(envsetup)
library(tern)
library(dplyr)
library(rtables)
library(junco)

# Define output ID and file location:

tblid <- "TSIDS02a"
fileid <- tblid
popfl <- "FASFL"
trtvar <- "TRT01P"
tab_titles <- get_titles_from_file(input_path = '../../_data/', tblid)
string_map <- default_str_map

# Process data:

adsl <- pharmaverseadamjnj::adsl

no_data_to_report <- function(df, var) {
  if (sum(is.na(df[[var]])) == length(df[[var]])) {
    df[[var]] <- factor(NA_character_, levels = "No data to report")
  }
  return(df)
}

adsl <- no_data_to_report(df = adsl, var = "DCTREAS")
adsl <- no_data_to_report(df = adsl, var = "DCSREAS")

adsl <- adsl %>%
  filter(!!rlang::sym(popfl) == "Y") %>%
  select(
    USUBJID,
    !!rlang::sym(trtvar),
    !!rlang::sym(popfl),
    SAFFL,
    PPROTFL,
    EOTSTT,
    DCTREAS,
    EOSSTT,
    DCSREAS,
    RACE_DECODE
  ) %>%
  create_colspan_var(
    non_active_grp = "Placebo",
    non_active_grp_span_lbl = " ",
    active_grp_span_lbl = "Active Study Agent",
    colspan_var = "colspan_trt",
    trt_var = trtvar
  ) %>%
  mutate(
    rrisk_header = "Risk Difference (%) 95% CI",
    rrisk_label = paste(!!rlang::sym(trtvar), "vs Placebo")
  )

# Added since label_fstr not working with cpct_relrisk
adsl$RACE <- as.factor(as.character(ifelse(
  is.na(adsl$RACE_DECODE),
  NA,
  paste("Race:", adsl$RACE_DECODE)
)))

colspan_trt_map <- create_colspan_map(
  adsl,
  non_active_grp = "Placebo",
  non_active_grp_span_lbl = " ",
  active_grp_span_lbl = "Active Study Agent",
  colspan_var = "colspan_trt",
  trt_var = trtvar
)
ref_path <- c("colspan_trt", " ", trtvar, "Placebo")

# Define layout and build table:

totdf <- tribble(
  ~valname , ~label  , ~levelcombo                                                 , ~exargs ,
  "Total"  , "Total" , c("Xanomeline High Dose", "Xanomeline Low Dose", "Placebo") , list()
)


extra_args1 <- list(
  denom = "n_altdf",
  denom_by = "RACE",
  riskdiff = FALSE,
  .stats = "count_unique"
)
extra_args2 <- list(
  denom = "n_altdf",
  denom_by = "RACE",
  riskdiff = FALSE,
  .stats = "count_unique_fraction"
)
extra_args3 <- list(
  denom = "n_altdf",
  denom_by = "RACE",
  riskdiff = TRUE,
  method = "wald",
  .stats = "count_unique_fraction",
  ref_path = ref_path
)


lyt <- basic_table(
  show_colcounts = TRUE,
  colcount_format = "N=xx",
  top_level_section_div = " "
) %>%
  split_cols_by(
    "colspan_trt",
    split_fun = trim_levels_to_map(map = colspan_trt_map)
  ) %>%
  split_cols_by(trtvar) %>%
  split_cols_by(
    trtvar,
    split_fun = add_combo_levels(totdf, keep_levels = "Total"),
    nested = FALSE
  ) %>%
  split_cols_by("rrisk_header", nested = FALSE) %>%
  split_cols_by(
    trtvar,
    labels_var = "rrisk_label",
    split_fun = remove_split_levels("Placebo")
  ) %>%
  split_rows_by("RACE", split_fun = drop_split_levels, section_div = " ") %>%
  summarize_row_groups(
    "RACE",
    cfun = a_freq_j,
    indent_mod = 0L,
    # na_str = " ",
    extra_args = extra_args1
  ) %>%
  # Analysis sets
  analyze(
    popfl,
    var_labels = "Analysis set:",
    afun = a_freq_j,
    extra_args = append(extra_args2, list(label = "Full", val = "Y")),
    show_labels = "visible"
  ) %>%
  analyze(
    "SAFFL",
    afun = a_freq_j,
    extra_args = append(extra_args2, list(label = "Safety", val = "Y")),
    show_labels = "hidden",
    indent_mod = 1
  ) %>%
  analyze(
    "PPROTFL",
    afun = a_freq_j,
    extra_args = append(
      extra_args2,
      list(label = "Per protocol", val = "Y", extrablankline = TRUE)
    ),
    show_labels = "hidden",
    indent_mod = 1,
    na_str = " "
  ) %>%
  #  Ongoing
  analyze(
    "EOSSTT",
    show_labels = "hidden",
    afun = a_freq_j,
    na_str = " ",
    extra_args = append(
      extra_args2,
      list(val = "ONGOING", label = "Subjects ongoing", extrablankline = TRUE)
    )
  ) %>%
  # Treatment disposition
  analyze(
    "EOTSTT",
    table_names = "Compl_Trt",
    show_labels = "hidden",
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(label = "Completed treatment", val = "COMPLETED")
    )
  ) %>%
  analyze(
    "EOTSTT",
    table_names = "DC_Trt",
    show_labels = "hidden",
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(label = "Discontinued treatment", val = "DISCONTINUED")
    )
  ) %>%
  analyze(
    "DCTREAS",
    show_labels = "hidden",
    indent_mod = 1,
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(extrablankline = TRUE, drop_levels = TRUE)
    )
  ) %>%
  # Study disposition
  analyze(
    "EOSSTT",
    table_names = "Compl_Study",
    show_labels = "hidden",
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(label = "Completed study", val = "COMPLETED")
    )
  ) %>%
  analyze(
    "EOSSTT",
    show_labels = "hidden",
    table_names = "DC_Study",
    afun = a_freq_j,
    extra_args = append(
      extra_args3,
      list(label = "Discontinued study", val = "DISCONTINUED")
    )
  ) %>%
  analyze(
    "DCSREAS",
    show_labels = "hidden",
    indent_mod = 1,
    afun = a_freq_j,
    extra_args = append(extra_args3, list(drop_levels = TRUE))
  )

result <- build_table(lyt, adsl, alt_counts_df = adsl)

# Post-Processing

# Remove the N=xx column headers for the risk difference columns
result <- remove_col_count(result, span_label_var = "rrisk_header")

# Sort DCTREAS and DCSREAD by descending total column.
result <- result %>%
  sort_at_path(
    path = c("RACE", "*", "DCTREAS"),
    scorefun = jj_complex_scorefun(colpath = "Total", lastcat = "Other")
  ) %>%
  sort_at_path(
    path = c("RACE", "*", "DCSREAS"),
    scorefun = jj_complex_scorefun(colpath = "Total")
  )

result <- prune_table(
  result,
  prune_func = remove_rows(removerowtext = "No data to report")
)

# Add titles and footnotes:

result <- set_titles(result, tab_titles)

# Convert to tbl file and output table:

tt_to_tlgrtf(string_map = string_map, tt = result, file = fileid, orientation = "landscape")
```
```{r result1, echo=FALSE, message=FALSE, warning=FALSE, test = list(result_v1 = "result")}
tt_to_flextable_j(result, tblid, string_map = string_map) 
```

[Download RTF file](`r paste0(tolower(tblid), '.rtf')`)
::::

Made with ❤️ by the J&J Team

  • Edit this page
  • Report an issue
Cookie Preferences