Skip to contents

Demographic Characteristics Table

Usage

adsl_summary(
  datain,
  vars,
  stat_vars = "n~minmaxc~mean(sd)~median~q1q3",
  pctdisp = "TRT",
  total_catyn = "N",
  total_catlabel = "Total",
  miss_catyn = "N",
  miss_catlabel = "Missing",
  pctsyn = "Y",
  sigdec_stat = 2,
  sigdec_cat = 2,
  a_subset = NA_character_,
  denom_subset = NA_character_,
  sparseyn = "N",
  sparsebyvalyn = "N"
)

Arguments

datain

Input data from mentry() output

vars

Names of adsl variables to display (Add "-S" to numeric variables), tilde-separated

stat_vars

Statistics to display in table for numeric vars, tilde-separated.

pctdisp

Method to calculate denominator (for %) by. Possible values: "TRT", "VAR", "COL", "SUBGRP", "CAT", "NONE", "NO", "DPTVAR", "BYVARxyN"

total_catyn

To return a 'Total' row for the categories of dptvar variable or not. Possible values: "Y"/"N"

total_catlabel

Label for total category row. eg- "All"/"Total"

miss_catyn

To include empty/blank values as miss_catlabel in categories of dptvar variable or not. Values: "Y"/"N"

miss_catlabel

Label for missing values

pctsyn

Display Percentage Sign in table or not. Values: "Y"/"N"

sigdec_stat

Number of base decimal places to retain in output of summary statistic. Applies to mean, min, max, sd etc

sigdec_cat

Number of decimal places for % displayed in output

a_subset

Analysis Subset condition; tilde-separated for each variable in vars.

denom_subset

Subset condition to be applied to dataset for calculating denominator, tilde-separated for categorical variables within vars.

sparseyn

To sparse missing categories/treatments or not? "Y"/"N"

sparsebyvalyn

Sparse missing categories within by groups. "Y"/"N"

Value

data.frame to be passed on to tbl_processor and tbl_display

Details

  • vars should contain all variables for analysis with "-S" added to numeric/summary stat variables, the remaining being for categorical analysis. eg. for "AGEGR1/AGEGR1N~AGE-S~SEX/SEXN~BMIBL-S", AGEGR1 and SEX will be analysed by category and AGE and BMIBL as summary statistics.

  • Argument stat_vars should contain names of statistic to apply to all summary analysis variables. sigdec applies only to statistical analysis of numeric variables (-S)

  • Arguments pctdisp, total_catyn, miss_catyn, miss_catlabel apply to all variables under categorical analyses.

  • a_subset should tilde-separated subset conditions, corresponding to each variable in vars. Length should be 1 or number of variables in vars. If only 1 condition is given, it will apply to all variables.

  • denom_subset, commonly used only when pctdisp is "SUBGRP" or "DPTVAR" corresponds to categorical variables within vars. eg. for "AGEGR1~AGE-S~SEX~BMIBL-S", there should be 2 tilde-separated conditions like "!is.na(USUBJID)~!is.na(SITEID)". If only 1 condition is given, it will apply to all categorical/discrete variables.

Examples

data(adsl)

mentry_df <- adsl |>
  mentry(
    subset = NA_character_,
    byvar = NA_character_,
    trtvar = "TRT01A",
    trtsort = "TRT01AN",
    subgrpvar = NA_character_,
    trttotalyn = "Y",
    add_grpmiss = "N",
    pop_fil = "SAFFL"
  )

adsl_sum <- mentry_df |>
  adsl_summary(
    vars = "AGEGR1/AGEGR1N~AGE-S~SEX/SEXN~RACE/RACEN",
    a_subset = "AGE<65~AGE>80~SEX=='F'~NA"
  )
#> mcatstat success
#> mcatstat success
#> mcatstat success
#> msum success

adsl_sum |>
  display_bign_head(mentry_data = mentry_df) |>
  tbl_processor(
    statlabel = "N~Range~Meansd~Median~Q1Q3",
    dptlabel = "Age Group~_NONE_~Sex~Race",
    addrowvar = "DPTVAR"
  ) |>
  tbl_display() |>
  flextable::autofit()

Placebo (N=86)

Xanomeline Low Dose (N=84)

Xanomeline High Dose (N=84)

Total (N=254)

Age Group

  <65

14 (16.28%)

8 ( 9.52%)

11 (13.10%)

33 (12.99%)

  N

30

29

18

77

  Range

(81.00,89.00)

(81.00,88.00)

(81.00,88.00)

(81.00,89.00)

  Meansd

84.03 (2.51)

83.41 (2.08)

83.44 (2.12)

83.66 (2.26)

  Median

84.00

83.00

83.50

84.00

  Q1Q3

(81.00, 86.00)

(82.00, 84.00)

(82.00, 85.00)

(82.00, 85.00)

Sex

  F

53 (61.63%)

50 (59.52%)

40 (47.62%)

143 (56.30%)

Race

  WHITE

78 (90.70%)

78 (92.86%)

74 (88.10%)

230 (90.55%)

  BLACK OR AFRICAN AMERICAN

8 ( 9.30%)

6 ( 7.14%)

9 (10.71%)

23 ( 9.06%)

  AMERICAN INDIAN OR ALASKA NATIVE

0

0

1 ( 1.19%)

1 ( 0.39%)

# Same variable with 2 unique subset conditions adsl_sum <- mentry_df |> adsl_summary( vars = "AGEGR1~AGE-S~SEX~SEX~RACE", a_subset = "AGE<65~AGE>80~SEX=='F'~SEX=='M'~NA" ) #> mcatstat success #> mcatstat success #> mcatstat success #> mcatstat success #> msum success adsl_sum |> display_bign_head(mentry_data = mentry_df) |> tbl_processor( statlabel = "N~Range~Meansd~Median~IQR", dptlabel = "Age Group~_NONE_~Sex1~Sex2~Race", addrowvar = "DPTVAR" ) |> tbl_display() |> flextable::autofit()

Placebo (N=86)

Xanomeline Low Dose (N=84)

Xanomeline High Dose (N=84)

Total (N=254)

Age Group

  <65

14 (16.28%)

8 ( 9.52%)

11 (13.10%)

33 (12.99%)

  N

30

29

18

77

  Range

(81.00,89.00)

(81.00,88.00)

(81.00,88.00)

(81.00,89.00)

  Meansd

84.03 (2.51)

83.41 (2.08)

83.44 (2.12)

83.66 (2.26)

  Median

84.00

83.00

83.50

84.00

  IQR

(81.00, 86.00)

(82.00, 84.00)

(82.00, 85.00)

(82.00, 85.00)

Sex1

  F

53 (61.63%)

50 (59.52%)

40 (47.62%)

143 (56.30%)

Sex2

  M

33 (38.37%)

34 (40.48%)

44 (52.38%)

111 (43.70%)

Race

  WHITE

78 (90.70%)

78 (92.86%)

74 (88.10%)

230 (90.55%)

  BLACK OR AFRICAN AMERICAN

8 ( 9.30%)

6 ( 7.14%)

9 (10.71%)

23 ( 9.06%)

  AMERICAN INDIAN OR ALASKA NATIVE

0

0

1 ( 1.19%)

1 ( 0.39%)

# participants in each data analysis set mentry_df |> adsl_summary( vars = "ITTFL~SAFFL~DISCONFL", a_subset = "ITTFL=='Y'~SAFFL=='Y'~DISCONFL=='Y'" ) |> display_bign_head(mentry_df) |> tbl_processor( statlabel = "N", dptlabel = "Intent-to-treat (n%)~Safety (n%)~Discontinued (n%)", disp_value_col = "N" ) |> tbl_display() |> flextable::autofit() #> mcatstat success #> mcatstat success #> mcatstat success

Placebo (N=86)

Xanomeline Low Dose (N=84)

Xanomeline High Dose (N=84)

Total (N=254)

Intent-to-treat (n%)

86 (100.00%)

84 (100.00%)

84 (100.00%)

254 (100.00%)

Safety (n%)

86 (100.00%)

84 (100.00%)

84 (100.00%)

254 (100.00%)

Discontinued (n%)

28 (32.56%)

59 (70.24%)

57 (67.86%)

144 (56.69%)

# with groups and subgroups mentry_df_grouped <- adsl |> mentry( subset = NA_character_, byvar = "SEX", trtvar = "TRT01A", trtsort = "TRT01AN", subgrpvar = "ETHNIC", trttotalyn = "N", add_grpmiss = "N", sgtotalyn = "Y", pop_fil = "SAFFL" ) adsl_sum_grouped <- mentry_df_grouped |> adsl_summary( vars = "AGEGR1~AGE-S~RACE" ) #> mcatstat success #> mcatstat success #> msum success adsl_sum_grouped |> display_bign_head(mentry_df_grouped) |> tbl_processor( statlabel = "N~Range~Meansd~Median~IQR", dptlabel = "Age Group~Age~Race", addrowvar = "DPTVAR" ) |> tbl_display( bylabel = "Sex", ) |> flextable::autofit()

Sex

Placebo (N=86)

Xanomeline Low Dose (N=84)

Xanomeline High Dose (N=84)

HISPANIC OR LATINO (N=3)

NOT HISPANIC OR LATINO (N=83)

Total (N=86)

HISPANIC OR LATINO (N=6)

NOT HISPANIC OR LATINO (N=78)

Total (N=84)

HISPANIC OR LATINO (N=3)

NOT HISPANIC OR LATINO (N=81)

Total (N=84)

F

Age Group

  <65

1 ( 1.16%)

8 ( 9.30%)

9 (10.47%)

2 ( 2.38%)

3 ( 3.57%)

5 ( 5.95%)

1 ( 1.19%)

4 ( 4.76%)

5 ( 5.95%)

  65-80

0

22 (25.58%)

22 (25.58%)

1 ( 1.19%)

27 (32.14%)

28 (33.33%)

0

28 (33.33%)

28 (33.33%)

  >80

1 ( 1.16%)

21 (24.42%)

22 (25.58%)

1 ( 1.19%)

16 (19.05%)

17 (20.24%)

0

7 ( 8.33%)

7 ( 8.33%)

Age

  N

2

51

53

4

46

50

1

39

40

  Range

(63.00,86.00)

(59.00,89.00)

(59.00,89.00)

(56.00,82.00)

(54.00,87.00)

(54.00,87.00)

(56.00,56.00)

(56.00,88.00)

(56.00,88.00)

  Meansd

74.50 (16.26)

76.43 (8.60)

76.36 (8.73)

65.50 (12.37)

76.57 (7.15)

75.68 (8.09)

56.00 (-)

75.15 (7.14)

74.67 (7.67)

  Median

74.50

78.00

78.00

62.00

78.00

77.50

56.00

76.00

76.00

  IQR

(63.00, 86.00)

(70.00, 84.00)

(70.00, 84.00)

(56.00, 75.00)

(73.00, 81.00)

(72.00, 81.00)

(56.00, 56.00)

(72.00, 79.00)

(72.00, 79.00)

Race

  WHITE

2 ( 2.33%)

46 (53.49%)

48 (55.81%)

4 ( 4.76%)

40 (47.62%)

44 (52.38%)

1 ( 1.19%)

33 (39.29%)

34 (40.48%)

  BLACK OR AFRICAN AMERICAN

0

5 ( 5.81%)

5 ( 5.81%)

0

6 ( 7.14%)

6 ( 7.14%)

0

6 ( 7.14%)

6 ( 7.14%)

M

Age Group

  <65

1 ( 1.16%)

4 ( 4.65%)

5 ( 5.81%)

0

3 ( 3.57%)

3 ( 3.57%)

2 ( 2.38%)

4 ( 4.76%)

6 ( 7.14%)

  65-80

0

20 (23.26%)

20 (23.26%)

1 ( 1.19%)

18 (21.43%)

19 (22.62%)

0

27 (32.14%)

27 (32.14%)

  >80

0

8 ( 9.30%)

8 ( 9.30%)

1 ( 1.19%)

11 (13.10%)

12 (14.29%)

0

11 (13.10%)

11 (13.10%)

Age

  N

1

32

33

2

32

34

2

42

44

  Range

(64.00,64.00)

(52.00,85.00)

(52.00,85.00)

(78.00,84.00)

(51.00,88.00)

(51.00,88.00)

(56.00,63.00)

(56.00,86.00)

(56.00,86.00)

  Meansd

64.00 (-)

73.66 (8.10)

73.36 (8.15)

81.00 (4.24)

75.31 (8.82)

75.65 (8.69)

59.50 (4.95)

74.81 (7.64)

74.11 (8.16)

  Median

64.00

74.00

74.00

81.00

77.00

77.50

59.50

77.00

77.00

  IQR

(64.00, 64.00)

(69.50, 80.50)

(69.00, 80.00)

(78.00, 84.00)

(68.00, 82.00)

(68.00, 82.00)

(56.00, 63.00)

(70.00, 81.00)

(69.00, 80.50)

Race

  WHITE

1 ( 1.16%)

29 (33.72%)

30 (34.88%)

2 ( 2.38%)

32 (38.10%)

34 (40.48%)

2 ( 2.38%)

38 (45.24%)

40 (47.62%)

  BLACK OR AFRICAN AMERICAN

0

3 ( 3.49%)

3 ( 3.49%)

0

0

0

0

3 ( 3.57%)

3 ( 3.57%)

  AMERICAN INDIAN OR ALASKA NATIVE

0

0

0

0

0

0

0

1 ( 1.19%)

1 ( 1.19%)

## Demographics Characteristics - Full Analysis Set with `pharmaverseadam` datasets if (FALSE) { # \dontrun{ library(dplyr) library(tidyr) advs <- pharmaverseadam::advs |> filter( .data$PARAMCD %in% c("HEIGHT", "WEIGHT", "BMI"), .data$ABLFL == "Y" ) |> select(all_of(c("USUBJID", "PARAMCD", "AVAL"))) |> pivot_wider( id_cols = "USUBJID", names_from = "PARAMCD", values_from = "AVAL" ) adsl_vs <- pharmaverseadam::adsl |> adsl_merge( dataset_add = advs, adsl_subset = "toupper(TRT01A) != 'SCREEN FAILURE'" ) |> mentry( trtvar = "TRT01A", trttotalyn = "Y" ) adsl_vs |> adsl_summary( vars = "SEX~AGE-S~AGEGR1~RACE~ETHNIC~HEIGHT-S~WEIGHT-S~BMI-S", stat_vars = "median(minmax)~mean(sd)" ) |> display_bign_head(adsl_vs) |> tbl_processor( dptlabel = "Sex, n(%)~Age (Years)~Age Category (Years), n(%)~Race, n(%)~Ethnicity, n(%)~Height (cm)~Weight (kg)~BMI (kg/m2)", statlabel = "Median (Min, Max)~Mean (SD)", addrowvars = "DPTVAR" ) |> tbl_display() |> flextable::autofit() } # }