flat_table: Flat (proportional) tables In sjPlot/sjmisc: Data and Variable Transformation Functions

Description

This function creates a labelled flat table or flat proportional (marginal) table.

Usage

 ```1 2``` ```flat_table(data, ..., margin = c("counts", "cell", "row", "col"), digits = 2, show.values = FALSE) ```

Arguments

 `data` A data frame. May also be a grouped data frame (see 'Note' and 'Examples'). `...` One or more variables of `data` that should be printed as table. `margin` Specify the table margin that should be computed for proportional tables. By default, counts are printed. Use `margin = "cell"`, `margin = "col"` or `margin = "row"` to print cell, column or row percentages of the table margins. `digits` Numeric; for proportional tables, `digits` indicates the number of decimal places. `show.values` Logical, if `TRUE`, value labels are prefixed by the associated value.

Value

An object of class `ftable`.

Note

`data` may also be a grouped data frame (see `group_by`) with up to two grouping variables. Cross tables are created for each subgroup then.

`frq` for simple frequency table of labelled vectors.

Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27``` ```data(efc) # flat table with counts flat_table(efc, e42dep, c172code, e16sex) # flat table with proportions flat_table(efc, e42dep, c172code, e16sex, margin = "row") # flat table from grouped data frame. You need to select # the grouping variables and at least two more variables for # cross tabulation. library(dplyr) efc %>% group_by(e16sex) %>% select(e16sex, c172code, e42dep) %>% flat_table() efc %>% group_by(e16sex, e42dep) %>% select(e16sex, e42dep, c172code, n4pstu) %>% flat_table() # now it gets weird... efc %>% group_by(e16sex, e42dep) %>% select(e16sex, e42dep, c172code, n4pstu, c161sex) %>% flat_table() ```

sjPlot/sjmisc documentation built on Aug. 18, 2018, 10:11 a.m.