plot_prop: Plot the Proportion of Each Predictor Level Having a Specific...

Description Usage Arguments Value Figures Author(s) Examples

Description

Plot the proportion of each predictor level having a specific outcome level and the 95% confidence interval of the proportion.

Usage

1
2
  plot_prop(data, predictor, outcome, ref_level, ref_value = 0.5,
            add_n = TRUE, width = 0)

Arguments

data

The dataframe containing the predictor and outcome variables.

predictor

The predictor variable name.

outcome

The outcome variable name.

ref_level

A string providing the specific outcome level to show the proportions for.

ref_value

Defaults to 0.5. A numeric providing the proportion value of interest to compare to.

add_n

Defaults to TRUE. A logical indicating whether to add the total number of observations of each level to the plot.

width

Defaults to 0. A numeric providing the width of the error bars.

Value

Returns a ggplot object with the predictor levels on the x-axis and the proportion of values in the ref_level of the outcome on the y-axis.

Figures

Author(s)

Andrew Kostandy (andrew.kostandy@gmail.com)

Examples

1
2
3
4
5
6
7
8
diamonds2 <- diamonds %>%
  mutate(cut = fct_collapse(cut,
                            `>= Premium` = c("Premium", "Ideal"),
                            `<= Very Good` = c("Very Good", "Good",
                                               "Fair")))

plot_prop(diamonds2, clarity, cut, ref_level = ">= Premium",
          ref_value = 0.5, add_n = TRUE, width = 0)

AndrewKostandy/MLtoolkit documentation built on May 7, 2019, 9:51 p.m.