Skip to contents

Creates a flat contingency table from a list array, such as the result of tapply() when the applied function returns a named vector.

Usage

# S3 method for class 'list'
ftable(x, row.vars = NULL, col.vars = NULL, ...)

Arguments

x

A list with a dim attribute, typically produced by tapply(). Each element must be a vector of equal length and have identical names.

row.vars

row variables passed to ftable(). Defaults to all dimensions except those specified in col.vars.

col.vars

column variables passed to ftable(). Defaults to the dimension created from the names of the list elements.

...

further arguments passed to ftable().

Value

An object of class "ftable".

Details

Each list element is expanded into an additional dimension corresponding to the names of the returned vector. The resulting array is then passed to ftable().

This is particularly useful for displaying multi-dimensional summaries such as confidence intervals returned by meanCI(), where each cell contains several statistics (e.g. estimate, lower CI, upper CI).

The names of the vectors stored in the list elements become an additional dimension of the resulting array. By default, this new dimension is shown in the columns of the flat contingency table.

See also

Examples

if (FALSE) { # \dontrun{

x <- with(
  Pizza,
  tapply(
    temperature,
    list(area, driver),
    lumen::meanCI,
    na.rm = TRUE
  )
)

ftable(x)

ftable(
  x,
  row.vars = c(2, 3),
  col.vars = 1
)

} # }