gg_prop_var_by_demographics: Generate a ggplot2 for a two factorial variables - target...

Description Usage Arguments Details Value Examples

View source: R/gg_prop_var_by_demographics.R

Description

Function accepts target variables and demographic variables (factorial variables) and calculates the proportions of the target variable in the demographic variable cut. The function produces a bar chart of the target variable proportion as a demographic variable function.

Usage

1
2
3
4
5
6
gg_prop_var_by_demographics(
  x,
  target_variable,
  demographics = vars(...),
  arrange_desc = T
)

Arguments

x

a tbl() with the data.

target_variable

Target variable on which the demographic cuts will be made.

demographics

Demographics variables. The variables' levels affect ordering on the x axis

arrange_desc

Logical. arrange parameter.

Details

Use '$' to generate the desired graph. See example.

Value

Function accepts target variables and demographic variables (factorial variables) and calculates the proportions of the target variable in the demographic variable cut. The function produces a bar chart of the target variable proportion as a demographic variable function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
quality_assurance <- data.frame(
product_color = sample(c("Red", "Green", "Blue", "Orange"), size = 50, replace = T),
status = sample(c("pass", "fail"), size = 50, replace = T),
product_name = sample(c("Lea", "Rose", "Ruth"), size = 50, replace = T))

quality_assurance_plot <- gg_prop_var_by_demographics(quality_assurance,
                     target_variable = product_name,
                     demographics = vars(product_color, status))

quality_assurance_plot$product_color
quality_assurance_plot$status

sarid-ins/saridr documentation built on Nov. 10, 2020, 9:07 p.m.