Learn R Programming

lares (version 4.7)

crosstab: Weighted Cross Tabulation

Description

A cross-tabulation function with output similar to STATA, tidy friendly, with weights if needed. If only one dependent variable crossval() will be recommended; if two, then both variables will be crossed; if three, both variables will be crossed with third as weighted values.

Usage

crosstab(df, ..., prow = FALSE, pcol = FALSE, pall = FALSE,
  decimals = 2, keep_nas = TRUE, total = TRUE, order = TRUE)

Arguments

df

Data.frame.

...

Variables. Dependent and independent variables. If needed, third value should be the weight variable.

prow, pcol, pall

Boolean. Calculate percent values for rows, columns, or the whole table, respectively.

decimals

Integer. How many decimals should be returned?

keep_nas

Boolean. Keep NAs and count them as well?

total

Boolean. Return total values column?

order

Boolean. Sort columns and rows by frequencies? Else, will be sorted alphabetically.

See Also

Other Exploratory: corr_cross, corr_var, df_str, distr, freqs_df, freqs, gain_lift, get_tweets, missingness, plot_cats, plot_df, plot_nums, tree_var, trendsRelated