gg_outlier_bin: Create a Histogram with Outlier Bins

Description Usage Arguments See Also Examples

View source: R/outlier_bin.R

Description

Make a ggplot with 'geom_histogram' that contains outlier bins. Bins can be created for both floor and ceiling outliers. Code is experimental so expect some deviations from normal plotting, like messed-up grid lines.

Usage

1
2
3
gg_outlier_bin(x, var_name, cut_off_floor, cut_off_ceiling, col = "black",
  fill = "cornflowerblue", fill_outlier_bins = "forestgreen",
  binwidth = NULL)

Arguments

x

a dataframe.

var_name

the name of the variable to visualize.

cut_off_floor

the floor of the histogram, all values below it will be put in the same bin. If 'NA“ no floor bin is created.

cut_off_ceiling

the ceiling of the histogram, all values above it will be put in the same bin. If 'NA“ no ceiling bin is created.

col

the color of the histogram.

fill

the fill of the regular histogram bins.

fill_outlier_bins

the fill of the outlier bins, make them a separate color to stress there different nature.

binwidth

the binwidth of the histogram.

See Also

https://edwinth.github.io/blog/outlier-bins/

Examples

1
2
3
library(tidyverse)
data_frame(x = c(runif(100, 0, 1000), rnorm(1000, 500, 3))) %>%
 gg_outlier_bin("x", 520, 480)

EdwinTh/thatssorandom documentation built on Jan. 18, 2020, 2:55 p.m.