construct_table: Create One-Way Table

Description Usage Arguments Details Value

View source: R/table.R

Description

construct_table() summarizes a given variable in a one-way table with percentages. It is mostly a wrapper around tabyl() that allows more flexibility in ordering the output table.

Usage

1
2
3
4
5
6
7
construct_table(
  .data,
  .by,
  infreq = NULL,
  to_na = c("unknown", "missing", "NA", "N/A", "<NA>", "^$"),
  show_missing_levels = FALSE
)

Arguments

.data

A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr)

.by

The variable in .data to analyze; can be specified as a normal variable or as a string

infreq

Should the output be ordered by frequency? The default depends on the input type; see details.

show_missing_levels

Should all levels be shown, even if empty?

Details

By default, construct_table() will order factor inputs by their level and all other input by frequency. If infreq = TRUE, it will all input by frequency; if infreq = FALSE, it will order all input alpha-numerically. Note that the .by variable will be converted to a factor with levels ordered according to the output table, regardless of input type or ordering.

Value

A tibble holding the summary table


jesse-smith/covidCluster documentation built on March 9, 2021, 3:08 p.m.