This function summarizes your data in a specific way and returns an object
that can be converted into a latex table.
Usage
pt_data_inventory(
data,
by = ".total",
panel = by,
inner_summary = TRUE,
drop_miss = FALSE,
stacked = FALSE,
table = NULL,
summarize_all = TRUE,
all_name = "All data",
all_name_stacked = "Group Total",
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
datacontains exactly the records to be summarized; pmtables will not add or remove rows prior to summarizingdata- 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, thenMISSwill be dropped, but only when allMISSvalues are equal to zero.- stacked
If
TRUE, then independent summaries are created byouterand included in a single table (see examples).- table
a named list to use for renaming columns (see details and examples)
- summarize_all
if
TRUEthen a complete data summary will be appended to the bottom of the table whenstackedisFALSE.- all_name
a name to use for the complete data summary
- all_name_stacked
a name to use for the complete data summary when
stackedisTRUE.- dv_col
Character name of
DVcolumn.- bq_col
Character name of
BQLcolumn; seefind_bq_col().- id_col
Character name of
IDcolumn.- ...
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:
MISSis the number of data records whereDVis missing (NA) and where theBQL(orBLQ) column is0OBSis the number of data records whereDVis not missing (non-NA) and theBQL(orBLQ) column is0BQLare records where theBQL(orBLQ) column is not equal to0
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().
