df_props: Joint and conditional proportions

Description Usage Arguments Details Examples

Description

Uses a formula interface to specify how the proportions are to be calculated.

Usage

1
2
df_props(formula, data, as.percent = FALSE, ..., wide = FALSE,
  margins = FALSE, format = c("proportion", "percent", "count"))

Arguments

formula

the formula describing the relationship

data

a data frame (or you can pipe this in)

as.percent

show proportions in percent (e.g. multiply by 100)

...

statistics functions to be applied to the data, e.g. mean, sd, confidence(0.95)

wide

reformat the output as a cross-tabulation. This makes sense only when there are just two variables

margins

show the marginal probabilities. Makes the most sense if wide = TRUE.

format

Use just for internal purposes.

Details

Using | in the formula specifies a conditional proportion

Examples

1
2
3
4
5
df_props(mtcars, ~ cyl + gear) 
df_props(mtcars, ~ cyl | gear)
df_props(mtcars, ~ cyl + gear, wide = TRUE)
df_props(mtcars, ~ cyl + gear, margins = TRUE)
df_props(mtcars, ~ cyl | gear, margins = TRUE)

ProjectMOSAIC/mosaicModel documentation built on May 13, 2019, 1:35 a.m.