Learn R Programming

Hmisc (version 4.1-0)

histboxp: Use plotly to Draw Stratified Spike Histogram and Box Plot Statistics

Description

Uses plotly to draw horizontal spike histograms stratified by group, plus the mean (solid dot) and vertical bars for these quantiles: 0.05 (red, short), 0.25 (blue, medium), 0.50 (black, long), 0.75 (blue, medium), and 0.95 (red, short). The robust dispersion measure Gini's mean difference and the SD may optionally be added. These are shown as horizontal lines starting at the minimum value of x having a length equal to the mean difference or SD. Even when Gini's and SD are computed, they are not drawn unless the user clicks on their legend entry.

Spike histograms have the advantage of effectively showing the raw data for both small and huge datasets, and unlike box plots allow multi-modality to be easily seen.

Usage

histboxp(p = plotly::plot_ly(height=height), x, group = NULL,
         xlab=NULL, gmd=TRUE, sd=FALSE, bins = 100, wmax=190, mult=7)

Arguments

p

plotly graphics object if already begun

x

a numeric vector

group

a discrete grouping variable. If omitted, defaults to a vector of ones

xlab

x-axis label, defaults to labelled version include units of measurement if any

gmd

set to FALSE to not compute Gini's mean difference

sd

set to TRUE to compute the SD

bins

number of equal-width bins to use for spike histogram. If the number of distinct values of x is less than bins, the actual values of x are used.

wmax,mult

tweaks for margin to allocate

Value

a plotly object

See Also

histSpike, plot.describe, scat1d

Examples

Run this code
# NOT RUN {
dist <- c(rep(1, 500), rep(2, 250), rep(3, 600))
Distribution <- factor(dist, 1 : 3, c('Unimodal', 'Bimodal', 'Trimodal'))
x <- c(rnorm(500, 6, 1),
       rnorm(200, 3, .7), rnorm(50, 7, .4),
       rnorm(200, 2, .7), rnorm(300, 5.5, .4), rnorm(100, 8, .4))
histboxp(x=x, group=Distribution, sd=TRUE)
# }

Run the code above in your browser using DataLab