if (FALSE) {
# Histogram estimators can be useful when data has boundary constraints
set.seed(1)
df <- data.frame(x = rexp(1e3), y = rexp(1e3))
ggplot(df, aes(x, y)) +
geom_hdr(method = method_histogram()) +
geom_point(size = 1)
# The resolution of the histogram estimator can be set via `bins`
ggplot(df, aes(x, y)) +
geom_hdr(method = method_histogram(bins = c(8, 25))) +
geom_point(size = 1)
# By setting `smooth = TRUE`, we can graphically smooth the "blocky" HDRs
ggplot(df, aes(x, y)) +
geom_hdr(method = method_histogram(smooth = TRUE)) +
geom_point(size = 1)
# However, we need to set `nudgex` and `nudgey` to align the HDRs correctly
ggplot(df, aes(x, y)) +
geom_hdr(method = method_histogram(smooth = TRUE, nudgex = "left", nudgey = "down")) +
geom_point(size = 1)
# Can also be used with `get_hdr()` for numerical summary of HDRs
res <- get_hdr(df, method = method_histogram())
str(res)
}
Run the code above in your browser using DataLab