# Histogram estimators can be useful when data has boundary constraints
df <- data.frame(x = rexp(1e3))
# Strip chart to visualize 1-d data
p <- ggplot(df, aes(x)) +
geom_jitter(aes(y = 0), width = 0, height = 2) +
scale_y_continuous(name = NULL, breaks = NULL) +
coord_cartesian(ylim = c(-3, 3))
p
p + geom_hdr_rug(method = method_histogram_1d())
# The resolution of the histogram estimator can be set via `bins`
p + geom_hdr_rug(method = method_histogram_1d(bins = 5))
# Can also be used with `get_hdr_1d()` for numerical summary of HDRs
res <- get_hdr_1d(df$x, method = method_histogram_1d())
str(res)
Run the code above in your browser using DataLab