Skip to contents

Summary statistics for numeric data variable

Usage

msumstat(
  datain = NULL,
  a_subset = NA_character_,
  dptvar = NULL,
  statvar = "",
  sigdec = "",
  dptvarn = 1,
  sparsebyvalyn = "N",
  figyn = "N"
)

Arguments

datain

Input dataset from mentry()

a_subset

Analysis subset condition specific to this function.

dptvar

Numerical variable for analysis. eg: "AGE", "HEIGHTBL"

statvar

Tilde (~)-separated list of statistics to be computed. eg: "mean~median"

sigdec

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

dptvarn

Number to assign as 'DPTVARN', used for block sorting when multiple blocks are created to be combined.

sparsebyvalyn

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

figyn

Determine if output is for figure or not "Y"/"N"

Value

a list containing 2 elements

  • tsum - Dataset with statistics as rows, for table output

  • gsum - Dataset with statistics as columns, for plot output

Details

Current available statistics (values for statvar) : n (count per group), mean, median, sd (standard deviation), min, max, iqr (interquartile range), var (variance), sum, range ("min, max") mean(sd), median(minmax), q25/q1 (25 % quantile), q75/q3 (75 % quantile) , p10 (10% quantile), p5, p1, p90, p95, p99, q1q3 ("q25, q75"), whiskerlow, whiskerup (box lower/upper whiskers), outliers (boxplot outliers, tilde-separated output), geometric mean/sd/CI box = median~q25~q75~whiskerlow~whiskerup~outliers (Tukey's method)

Examples

data(adsl)

adsl_entry <- mentry(
  datain = adsl,
  subset = "EFFFL=='Y'",
  byvar = "SEX",
  trtvar = "TRT01A",
  trtsort = "TRT01AN",
  pop_fil = NA
)

adsl_sum <- adsl_entry |>
  msumstat(
    dptvar = "AGE",
    a_subset = "SEX == 'F'",
    statvar = "mean(sd)~median(minmaxc)~q3",
    sigdec = "3(2)~2(0)~1",
    sparsebyvalyn = "N"
  )
#> msum success

adsl_sum$tsum
#> # A tibble: 9 × 9
#>   BYVAR1 BYVAR1N TRTVAR               DPTVAR CN    DPTVARN DPTVAL CVALUE DPTVALN
#>   <chr>    <dbl> <ord>                <chr>  <chr>   <dbl> <chr>  <glue>   <dbl>
#> 1 F            1 Placebo              AGE    N           1 mean(… 76.10…       1
#> 2 F            1 Placebo              AGE    N           1 media… 77.50…       2
#> 3 F            1 Placebo              AGE    N           1 q3     83.0         3
#> 4 F            1 Xanomeline Low Dose  AGE    N           1 mean(… 76.38…       1
#> 5 F            1 Xanomeline Low Dose  AGE    N           1 media… 78.00…       2
#> 6 F            1 Xanomeline Low Dose  AGE    N           1 q3     81.0         3
#> 7 F            1 Xanomeline High Dose AGE    N           1 mean(… 74.25…       1
#> 8 F            1 Xanomeline High Dose AGE    N           1 media… 76.00…       2
#> 9 F            1 Xanomeline High Dose AGE    N           1 q3     79.0         3
adsl_sum$gsum
#> # A tibble: 3 × 9
#>   BYVAR1 BYVAR1N TRTVAR  `mean(sd)` `median(minmaxc)` q3    DPTVAR CN    DPTVARN
#>   <chr>    <dbl> <ord>   <glue>     <glue>            <chr> <chr>  <chr>   <dbl>
#> 1 F            1 Placebo 76.109 (8… 77.50 (59,88)     83.0  AGE    N           1
#> 2 F            1 Xanome… 76.383 (7… 78.00 (56,87)     81.0  AGE    N           1
#> 3 F            1 Xanome… 74.257 (7… 76.00 (56,88)     79.0  AGE    N           1