This function summarizes your data in a specific way and returns an object that can be converted into a latex table.

pt_data_inventory(
  data,
  by = ".total",
  panel = by,
  inner_summary = TRUE,
  drop_miss = FALSE,
  stacked = FALSE,
  table = NULL,
  all_name = "all",
  dv_col = "DV",
  bq_col = find_bq_col(data),
  id_col = "ID",
  ...
)

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

by

The outer grouping variable; may be character or quosure.

panel

The panel grouping variable; may be character or quosure.

inner_summary

If TRUE, then a summary of the inner variable will be provided.

drop_miss

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

stacked

If TRUE, then independent summaries are created by outer and included in a single table (see examples).

table

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

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.

...

Other arguments passed to data_inventory_chunk().

Value

An object with class pmtable; see class-pmtable.

Details

Output columns include counts for subjects (SUBJ), observations (OBS), BQL observations, missing observations (MISS) and percentage of observations that are BQL. When panels are requested, then the percentages for OBS and BQL are presented for the Overall data and for the panel Group.

Specifically, please note that:

  • MISS is the number of data records where DV is missing (NA) and where the BQL (or BLQ) column is 0

  • OBS is the number of data records where DV is not missing (non-NA) and the BQL (or BLQ) column is 0

  • BQL are records where the BQL (or BLQ) column is not equal to 0

The sum of MISS + OBS + BQL should equal the number of rows in the data frame passed to pt_data_inventory().

When calculating percent OBS and percent BQL, we use OBS + BQL as the denominator such that the percent BQL and percent OBS sum to 100 within a group or panel. When the panel argument is set, these percentages are calculated for the group (or panel) as well as overall. In other words, records that are MISS are not factored into totals for OBS or BQL and similarly are not factored into calculation of percent OBS or percent BQL. The summary function is expecting certain columns to be named in a certain way. This can be modified to suit your need by passing the following arguments: dv_col (for observations), bq_col (for BQL observations), and id_col (for ID). For example, if BQL indicator is in a column called BELOW you would pass bq_col = BELOW.

See the data_inventory_chunk() help topic for a description of these columns.

The notes for this table are generated by pt_data_inventory_notes().

Examples


ans <- pt_data_inventory(pmt_pk, by = c("Renal function" = "RFf"))

ans <- pt_data_inventory(
   pmt_pk,
   by = "STUDYf",
   panel = "RFf"
)

ans <- pt_data_inventory(
   pmt_obs,
   by = "STUDYf",
   panel = "SEQf",
   stacked = TRUE
)

if (FALSE) {
st2report(stable(ans))
}