crosstable: Build an attractive cross-tabulation

Description Usage Arguments Details Value Examples

View source: R/crosstabs.R

Description

Build an attractive cross-tabulation

Usage

1
2
crosstable(df, var1, var2, weight_var = NULL, margins = FALSE,
  percent = FALSE)

Arguments

df

a data.frame containing the variables to cross-tabulate.

var1

a character field name in df that will make the rows of the table.

var2

a character field name in df that will make the columns of the table.

weight_var

a character field name in df that weights the data. If NULL, will treat each record equally.

margins

boolean, should the row and column sums be appended? default FALSE

percent

boolean, should the table be a percentage? default FALSE

Details

If var1,var2 are numeric vectors, then the name of the field will be prepended to the row or column names. If not, then the bare attribute name will be given.

Value

an array that can be cast with kable() or examined directly.

Examples

1
2
3
4
crosstable(links, "facility_group", "area_name")
crosstable(links, "facility_group", "area_name", margins = TRUE)
crosstable(links, "facility_group", "area_name", percent = TRUE)
crosstable(links, "facility_group", "area_type", percent = TRUE)

pbsag/outviz documentation built on Dec. 7, 2019, 5:50 a.m.