Coerce a spicy_categorical_table to a plain data frame or tibble
Source: R/table_categorical_print.R
as.data.frame.spicy_categorical_table.Rdas.data.frame() returns the table table_categorical() displays,
with its numbers: exactly what output = "data.frame" returns. One
row per printed row – the header row of each variable, which
carries its p-value and its association measure, then one row per
level – and the printed columns under their names ("Female n",
"Female %", ..., "p", the measure), plus the key columns
variable (the column name), label (the label displayed for it),
level, and .row_role ("factor_header", "level", "missing"
for the row of missing values the table adds, or "total" for the
Total row of total_row = TRUE). The note,
as printed, is kept in attr(, "note"). as_tibble() returns the
same table as a tibble.
Usage
# S3 method for class 'spicy_categorical_table'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)
# S3 method for class 'spicy_categorical_table'
as_tibble(x, ...)Arguments
- x
A
spicy_categorical_tablereturned bytable_categorical().- row.names, optional
Standard
base::as.data.frame()arguments. Currently ignored.- ...
Further arguments passed to
tibble::as_tibble()(for the tibble method) or ignored (for theas.data.frame()method).
Details
For one row per variable, level and group, use output = "long" or
tidy.spicy_categorical_table(). The original x is unaffected, and
print(x) continues to render the formatted ASCII table.