Generates a table showing numbers of subjects and observations, stratifying by multiple categorical covariates.

pt_inventory_long(
  data,
  cols,
  drop_miss = FALSE,
  table = NULL,
  summarize_all = TRUE,
  all_name = "All data",
  dv_col = "DV",
  bq_col = find_bq_col(data),
  id_col = "ID",
  level_width = NULL
)

pt_data_inventory_long(
  data,
  cols,
  drop_miss = FALSE,
  table = NULL,
  summarize_all = TRUE,
  all_name = "All data",
  dv_col = "DV",
  bq_col = find_bq_col(data),
  id_col = "ID",
  level_width = NULL
)

Arguments

data

the data frame to summarize; the user should filter or subset so that data contains exactly the records to be summarized; pmtables will not add or remove rows prior to summarizing data

cols

data columns containing discrete data items for grouped data inventory summaries.

drop_miss

If TRUE, then MISS will be dropped, but only when all MISS values are equal to zero.

table

a named list to use for renaming columns (see details and examples)

summarize_all

if TRUE then a complete data summary will be appended to the bottom of the table when stacked is FALSE.

all_name

a name to use for the complete data summary

dv_col

Character name of DV column.

bq_col

Character name of BQL column; see find_bq_col().

id_col

Character name of ID column.

level_width

width in cm of the level column, the left-most column containing the different levels of the discrete data items specified in cols.

Examples


data <- pmt_first

tab <- pt_inventory_long(data, cols = c("FORMf", "SEXf", "RFf"))

tab$data
#> # A tibble: 10 × 8
#>    var   level         Number.SUBJ Number.MISS Number.OBS Number.BQL Percent.OBS
#>    <chr> <chr>               <int>       <int>      <int>      <int> <chr>      
#>  1 FORMf "tablet"              130           1        121          8 76.1       
#>  2 FORMf "capsule"              15           0         14          1 8.8        
#>  3 FORMf "troche"               15           0         14          1 8.8        
#>  4 SEXf  "male"                 80           1         73          6 45.9       
#>  5 SEXf  "female"               80           0         76          4 47.8       
#>  6 RFf   "normal"              130           1        121          8 76.1       
#>  7 RFf   "mild"                 10           0         10          0 6.3        
#>  8 RFf   "moderate"             10           0          9          1 5.7        
#>  9 RFf   "severe"               10           0          9          1 5.7        
#> 10 NULL  "\\hline \\h…         160           1        149         10 93.7       
#> # ℹ 1 more variable: Percent.BQL <chr>