pt_cat_wide: Discrete data summary in long format

View source: R/discrete_table.R

pt_cat_wideR Documentation

Discrete data summary in long format

Description

Discrete data summary in long format

Usage

pt_cat_wide(
  data,
  cols,
  by = ".total",
  panel = by,
  table = NULL,
  all_name = "All data",
  summarize = c("bottom", "none"),
  complete = FALSE,
  denom = c("group", "total")
)

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

the columns to summarize; may be character vector or quosure

by

a grouping variable for the summary; may be given as character vector or quosure.

panel

data set column name to stratify the summary

table

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

all_name

a name to use for the complete data summary

summarize

where to put an all-data summary; choose none to omit the summary from the table.

complete

logical; if TRUE, then data the summary will be completed for missing levels of byand panel.

denom

the denominator to use when calculating percent for each level; group uses the total number in the chunk being summarized; total uses the total number in the data set; historically, group has been used as the default.

Details

The data summary for this table is count (percent). The number of data points for each row is also summarized as n on the left hand side of the table (either on the far left or just to the right of the by column).

When group is selected for denom, percent is calculated with denominator set to n, the total for each row. When total is selected for denom, then percent is calculated by the total number of records in the input data.

The notes in this table are generated with pt_cat_wide_notes().

Value

An object with class pmtable; see class-pmtable.

Examples

out1 <- pt_cat_wide(pmt_first, cols = "SEXf,ASIANf")
stable(out1)

out2 <- pt_cat_wide(pmt_first, cols = "SEXf,ASIANf", by = "FORMf")
stable(out2)

## Not run: 
st2report(stable(out1))
st2report(stable(out2))

## End(Not run)


metrumresearchgroup/pmtables documentation built on Dec. 22, 2024, 1:34 a.m.