histogram_w_outlier_bins: Histogram with outlier bins

View source: R/histogram_w_outlier_bins.R

histogram_w_outlier_binsR Documentation

Histogram with outlier bins

Description

Create a histogram with outlier bins

Usage

histogram_w_outlier_bins(
  vector = NULL,
  bin_cutoffs = NULL,
  outlier_bin_left = TRUE,
  outlier_bin_right = TRUE,
  x_tick_marks = NULL,
  x_tick_mark_labels = NULL,
  y_tick_marks = NULL,
  outlier_bin_fill_color = "coral",
  non_outlier_bin_fill_color = "cyan4",
  border_color = "black",
  y_axis_title_vjust = 0.85,
  x_axis_title = NULL,
  y_axis_title = NULL,
  notify_na_count = NULL,
  plot_proportion = TRUE,
  plot_frequency = FALSE,
  mean = TRUE,
  ci = TRUE,
  median = TRUE,
  median_position = 15,
  error_bar_size = 3
)

Arguments

vector

a numeric vector

bin_cutoffs

cutoff points for bins

outlier_bin_left

logical. Should the leftmost bin treated as an outlier bin? (default = TRUE)

outlier_bin_right

logical. Should the rightmost bin treated as an outlier bin? (default = TRUE)

x_tick_marks

a vector of values at which to place tick marks on the x axis. Note that the first bar spans from 0.5 to 1.5, second bar from 1.5 to 2.5, ... nth bar from n - 0.5 to n + 0.5. See the example. By default, tick marks will be placed at every cutoff point for bins

x_tick_mark_labels

a character vector to label tick marks. By default, the vector of cutoff points for bins will also be used as labels.

y_tick_marks

a vector of values at which to place tick marks on the y axis (e.g., setting y_tick_marks = seq(0, 10, 5) will put tick marks at 0, 5, and 10.)

outlier_bin_fill_color

color to fill inside of the outlier bins (default = "coral")

non_outlier_bin_fill_color

color to fill inside of the non-outlier bins (default = "cyan4")

border_color

color for borders of the bins (default = "black")

y_axis_title_vjust

position of the y axis title (default = 0.85).

x_axis_title

title for x axis (default = "Value"). If x_axis_title = FALSE, x axis title will be removed from the plot.

y_axis_title

title for y axis. By default, it will be either "Proportion" or "Count".

notify_na_count

if TRUE, notify how many observations were removed due to missing values. By default, NA count will be printed only if there are any NA values.

plot_proportion

logical. Should proportions be plotted, as opposed to frequencies? (default = TRUE)

plot_frequency

logical. Should frequencies be plotted, as opposed to proportions? (default = FALSE). If plot_frequency = TRUE, plot_proportion will switch to be FALSE.

mean

logical. Should mean marked on the histogram? (default = TRUE)

ci

logical. Should 95% confidence interval marked on the histogram? (default = TRUE)

median

logical. Should median marked on the histogram? (default = TRUE)

median_position

position of the median label as a percentage of height of the tallest bin (default = 15)

error_bar_size

size of the error bars (default = 3)

Value

a ggplot object

Examples


histogram_w_outlier_bins(vector = 1:100, bin_cutoffs = seq(0, 100, 10))
histogram_w_outlier_bins(vector = 0:89, bin_cutoffs = seq(0, 90, 10),
x_tick_marks = seq(0.5, 9.5, 3), x_tick_mark_labels = seq(0, 90, 30))
histogram_w_outlier_bins(vector = 1:10, bin_cutoffs = seq(0, 10, 2.5))
histogram_w_outlier_bins(vector = 1:5, bin_cutoffs = seq(0, 10, 2.5))
histogram_w_outlier_bins(vector = 1:15, bin_cutoffs = c(5.52, 10.5))


kim documentation built on Oct. 9, 2023, 5:08 p.m.