generate_xtab: Generate crosstabs

View source: R/generate_xtab.R

generate_xtabR Documentation

Generate crosstabs

Description

This function takes a data frame or a tibble object, a few variables, and a string caption, returning a list object that is an instance of class flextable. The function implements data masking internally so users must specify data variables as strings (i.e. use "x", "y", "weight").

Usage

generate_xtab(df, x, y, weight, caption)

Arguments

df

A data frame or tibble.

x

A single string of the independent variable.

y

A single string of the dependent variable.

weight

A single string of the weighting variable.

caption

A length one character vector used as the caption for the crosstab.

Value

A list object, which is an object of class flextable.

See Also

generate_xtab_3way() for three-way crosstabs.

Examples


# Generate a crosstab
df %>% generate_xtab(df = ., "x_var", "y_var", "weight", "X by Y")


YangWu1227/citizenr documentation built on June 18, 2022, 12:17 p.m.