Visualize the distribution of a single continuous variable by dividing the x axis into bins and counting the number of observations in each bin. Data points that are considered outliers can be binned together. This might be helpful to display numerical data over a very wide range of values in a compact way.
histbin(
data,
x,
left = NULL,
right = NULL,
line = FALSE,
bins = 30,
fill = NULL,
color = NULL,
fill_outliers = "#a7d1a7"
)
data.frame
variable name in data.frame data
that should be mapped
numeric indicating the floor of the range
numeric indicating the ceiling of the range
show density line (default is FALSE)
numeric to indicate number of bins
color used to fill bars
color for bar lines
color used to fill outlier bars
a ggplot2 object
Wrapper function around ggplot2::geom_histogram()
. The method is
based on suggestions from https://edwinth.github.io/blog/outlier-bin/.
histbin(MTPL2, premium)
histbin(MTPL2, premium, left = 30, right = 120, bins = 30)