From c42ca9dccbcdbee229230c1a320078b99eba77f1 Mon Sep 17 00:00:00 2001 From: echasnovski Date: Tue, 19 May 2020 18:59:43 +0300 Subject: [PATCH 1/8] Draft update `StatDensity` to have `bounds` argument. --- R/stat-density.r | 47 ++++++++++++++++++++++++++++++++++++++++----- man/geom_density.Rd | 4 ++++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/R/stat-density.r b/R/stat-density.r index c0c8bd0371..8585cd0857 100644 --- a/R/stat-density.r +++ b/R/stat-density.r @@ -15,6 +15,8 @@ #' not line-up, and hence you won't be able to stack density values. #' This parameter only matters if you are displaying multiple densities in #' one plot or if you are manually adjusting the scale limits. +#' @param bounds Known lower and upper bounds for estimated data. Default +#' `c(-Inf, Inf)` means that there are no (finite) bounds. #' @section Computed variables: #' \describe{ #' \item{density}{density estimate} @@ -35,6 +37,7 @@ stat_density <- function(mapping = NULL, data = NULL, n = 512, trim = FALSE, na.rm = FALSE, + bounds = c(-Inf, Inf), orientation = NA, show.legend = NA, inherit.aes = TRUE) { @@ -54,6 +57,7 @@ stat_density <- function(mapping = NULL, data = NULL, n = n, trim = trim, na.rm = na.rm, + bounds = bounds, orientation = orientation, ... ) @@ -84,7 +88,8 @@ StatDensity <- ggproto("StatDensity", Stat, extra_params = c("na.rm", "orientation"), compute_group = function(data, scales, bw = "nrd0", adjust = 1, kernel = "gaussian", - n = 512, trim = FALSE, na.rm = FALSE, flipped_aes = FALSE) { + n = 512, trim = FALSE, na.rm = FALSE, bounds = c(-Inf, Inf), + flipped_aes = FALSE) { data <- flip_data(data, flipped_aes) if (trim) { range <- range(data$x, na.rm = TRUE) @@ -93,7 +98,8 @@ StatDensity <- ggproto("StatDensity", Stat, } density <- compute_density(data$x, data$weight, from = range[1], - to = range[2], bw = bw, adjust = adjust, kernel = kernel, n = n) + to = range[2], bw = bw, adjust = adjust, kernel = kernel, n = n, + bounds = bounds) density$flipped_aes <- flipped_aes flip_data(density, flipped_aes) } @@ -101,7 +107,8 @@ StatDensity <- ggproto("StatDensity", Stat, ) compute_density <- function(x, w, from, to, bw = "nrd0", adjust = 1, - kernel = "gaussian", n = 512) { + kernel = "gaussian", n = 512, + bounds = c(-Inf, Inf)) { nx <- length(x) if (is.null(w)) { w <- rep(1 / nx, nx) @@ -122,8 +129,15 @@ compute_density <- function(x, w, from, to, bw = "nrd0", adjust = 1, ), n = 1)) } - dens <- stats::density(x, weights = w, bw = bw, adjust = adjust, - kernel = kernel, n = n, from = from, to = to) + if (all(is.infinite(bounds))) { + dens <- stats::density(x, weights = w, bw = bw, adjust = adjust, + kernel = kernel, n = n, from = from, to = to) + } else { + dens <- stats::density(x, weights = w, bw = bw, adjust = adjust, + kernel = kernel, n = n) + + dens <- reflect_density(dens = dens, bounds = bounds, from = from, to = to) + } new_data_frame(list( x = dens$x, @@ -134,3 +148,26 @@ compute_density <- function(x, w, from, to, bw = "nrd0", adjust = 1, n = nx ), n = length(dens$x)) } + +reflect_density <- function(dens, bounds, from, to) { + if (all(is.infinite(bounds))) { + return(dens) + } + + f_dens <- stats::approxfun( + x = dens$x, y = dens$y, method = "linear", yleft = 0, yright = 0 + ) + + out_x <- intersection_grid(dens$x, bounds, from, to) + out_y <- f_dens(out_x) + f_dens(bounds[1] + (bounds[1] - out_x)) + + f_dens(bounds[2] + (bounds[2] - out_x)) + + list(x = out_x, y = out_y) +} + +intersection_grid <- function(grid, bounds, from, to) { + left <- max(from, bounds[1]) + right <- min(to, bounds[2]) + + seq(from = left, to = right, length.out = length(grid)) +} diff --git a/man/geom_density.Rd b/man/geom_density.Rd index 600353296f..cad3fd5530 100644 --- a/man/geom_density.Rd +++ b/man/geom_density.Rd @@ -30,6 +30,7 @@ stat_density( n = 512, trim = FALSE, na.rm = FALSE, + bounds = c(-Inf, Inf), orientation = NA, show.legend = NA, inherit.aes = TRUE @@ -111,6 +112,9 @@ range of that group: this typically means the estimated x values will not line-up, and hence you won't be able to stack density values. This parameter only matters if you are displaying multiple densities in one plot or if you are manually adjusting the scale limits.} + +\item{bounds}{Known lower and upper bounds for estimated data. Default +\code{c(-Inf, Inf)} means that there are no (finite) bounds.} } \description{ Computes and draws kernel density estimate, which is a smoothed version of From 9c5eeef51b279dcf5e78ae4c79b082d445c3f934 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Thu, 12 May 2022 18:33:00 +0300 Subject: [PATCH 2/8] Refresh `bounds` usage in `StatDensity`. --- R/stat-density.r | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/R/stat-density.r b/R/stat-density.r index 8585cd0857..d53df7e8c2 100644 --- a/R/stat-density.r +++ b/R/stat-density.r @@ -16,7 +16,9 @@ #' This parameter only matters if you are displaying multiple densities in #' one plot or if you are manually adjusting the scale limits. #' @param bounds Known lower and upper bounds for estimated data. Default -#' `c(-Inf, Inf)` means that there are no (finite) bounds. +#' `c(-Inf, Inf)` means that there are no (finite) bounds. If any bound is +#' finite, boundary effect of default density estimation will be corrected by +#' reflecting tails outside `bounds` around their closest edge. #' @section Computed variables: #' \describe{ #' \item{density}{density estimate} @@ -129,14 +131,15 @@ compute_density <- function(x, w, from, to, bw = "nrd0", adjust = 1, ), n = 1)) } - if (all(is.infinite(bounds))) { - dens <- stats::density(x, weights = w, bw = bw, adjust = adjust, - kernel = kernel, n = n, from = from, to = to) - } else { + # Decide whether to use boundary correction + if (any(is.finite(bounds))) { dens <- stats::density(x, weights = w, bw = bw, adjust = adjust, kernel = kernel, n = n) dens <- reflect_density(dens = dens, bounds = bounds, from = from, to = to) + } else { + dens <- stats::density(x, weights = w, bw = bw, adjust = adjust, + kernel = kernel, n = n, from = from, to = to) } new_data_frame(list( @@ -149,25 +152,39 @@ compute_density <- function(x, w, from, to, bw = "nrd0", adjust = 1, ), n = length(dens$x)) } +# Update density estimation to mitigate boundary effect at known `bounds`: +# - All x values will lie inside `bounds`. +# - All y-values will be updated to have total probability of `bounds` be +# closer to 1. This is done by reflecting tails outside of `bounds` around +# their closest edge. This leads to those tails lie inside of `bounds` +# (completely, if they are not wider than `bounds` itself, which is a common +# situation) and correct boundary effect of default density estimation. +# +# `dens` - output of `stats::density`. +# `bounds` - two-element vector with left and right known (user supplied) +# bounds of x values. +# `from`, `to` - numbers used as corresponding arguments of `stats::density()` +# in case of no boundary correction. reflect_density <- function(dens, bounds, from, to) { + # No adjustment is needed if no finite bounds are supplied if (all(is.infinite(bounds))) { return(dens) } + # Estimate linearly with zero tails (crucial to account for infinite bound) f_dens <- stats::approxfun( x = dens$x, y = dens$y, method = "linear", yleft = 0, yright = 0 ) - out_x <- intersection_grid(dens$x, bounds, from, to) - out_y <- f_dens(out_x) + f_dens(bounds[1] + (bounds[1] - out_x)) + - f_dens(bounds[2] + (bounds[2] - out_x)) - - list(x = out_x, y = out_y) -} - -intersection_grid <- function(grid, bounds, from, to) { + # Create a uniform x-grid inside `bounds` left <- max(from, bounds[1]) right <- min(to, bounds[2]) + out_x <- seq(from = left, to = right, length.out = length(dens$x)) + + # Update density estimation by adding reflected tails from outside `bounds` + left_reflection <- f_dens(bounds[1] + (bounds[1] - out_x)) + right_reflection <- f_dens(bounds[2] + (bounds[2] - out_x)) + out_y <- f_dens(out_x) + left_reflection + right_reflection - seq(from = left, to = right, length.out = length(grid)) + list(x = out_x, y = out_y) } From 9bd40d4aa8fd06ffe0b2d9c536c7d97cd738b74f Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 12 Jul 2022 16:28:16 +0300 Subject: [PATCH 3/8] Handle data points outside of `bounds`. --- R/stat-density.r | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/R/stat-density.r b/R/stat-density.r index d53df7e8c2..dffae2112d 100644 --- a/R/stat-density.r +++ b/R/stat-density.r @@ -18,7 +18,8 @@ #' @param bounds Known lower and upper bounds for estimated data. Default #' `c(-Inf, Inf)` means that there are no (finite) bounds. If any bound is #' finite, boundary effect of default density estimation will be corrected by -#' reflecting tails outside `bounds` around their closest edge. +#' reflecting tails outside `bounds` around their closest edge. Data points +#' outside of bounds are removed with a warning. #' @section Computed variables: #' \describe{ #' \item{density}{density estimate} @@ -118,6 +119,12 @@ compute_density <- function(x, w, from, to, bw = "nrd0", adjust = 1, w <- w / sum(w) } + # Adjust data points and weights to all fit inside bounds + sample_data <- fit_data_to_bounds(bounds, x, w) + x <- sample_data$x + w <- sample_data$w + nx <- length(x) + # if less than 2 points return data frame of NAs and a warning if (nx < 2) { warn("Groups with fewer than two data points have been dropped.") @@ -152,6 +159,23 @@ compute_density <- function(x, w, from, to, bw = "nrd0", adjust = 1, ), n = length(dens$x)) } +# Check if all data points are inside bounds. If not, warn and remove them. +fit_data_to_bounds <- function(bounds, x, w) { + is_inside_bounds <- (bounds[1] <= x) & (x <= bounds[2]) + + if (any(!is_inside_bounds)) { + warn("Some data points are outside of `bounds`. Removing them.") + x <- x[is_inside_bounds] + w <- w[is_inside_bounds] + w_sum <- sum(w) + if (w_sum > 0) { + w <- w / w_sum + } + } + + return(list(x = x, w = w)) +} + # Update density estimation to mitigate boundary effect at known `bounds`: # - All x values will lie inside `bounds`. # - All y-values will be updated to have total probability of `bounds` be From dc6f4061cf9c559c8ff3e54517e306e158d2629d Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 12 Jul 2022 16:48:59 +0300 Subject: [PATCH 4/8] Update documentation with `bounds` example. --- R/geom-density.r | 6 ++++++ man/geom_density.Rd | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/R/geom-density.r b/R/geom-density.r index 9e4f5f406c..44c0862f3e 100644 --- a/R/geom-density.r +++ b/R/geom-density.r @@ -35,6 +35,12 @@ #' geom_density(alpha = 0.1) + #' xlim(55, 70) #' +#' # Use `bounds` to adjust computation for known data limits +#' big_diamonds <- diamonds[diamonds$carat >= 1, ] +#' ggplot(big_diamonds, aes(carat)) + +#' geom_density(color = 'red') + +#' geom_density(bounds = c(1, Inf), color = 'blue') +#' #' \donttest{ #' # Stacked density plots: if you want to create a stacked density plot, you #' # probably want to 'count' (density * n) variable instead of the default diff --git a/man/geom_density.Rd b/man/geom_density.Rd index cad3fd5530..c30fc3219c 100644 --- a/man/geom_density.Rd +++ b/man/geom_density.Rd @@ -114,7 +114,10 @@ This parameter only matters if you are displaying multiple densities in one plot or if you are manually adjusting the scale limits.} \item{bounds}{Known lower and upper bounds for estimated data. Default -\code{c(-Inf, Inf)} means that there are no (finite) bounds.} +\code{c(-Inf, Inf)} means that there are no (finite) bounds. If any bound is +finite, boundary effect of default density estimation will be corrected by +reflecting tails outside \code{bounds} around their closest edge. Data points +outside of bounds are removed with a warning.} } \description{ Computes and draws kernel density estimate, which is a smoothed version of @@ -174,6 +177,12 @@ ggplot(diamonds, aes(depth, fill = cut, colour = cut)) + geom_density(alpha = 0.1) + xlim(55, 70) +# Use `bounds` to adjust computation for known data limits +big_diamonds <- diamonds[diamonds$carat >= 1, ] +ggplot(big_diamonds, aes(carat)) + + geom_density(color = 'red') + + geom_density(bounds = c(1, Inf), color = 'blue') + \donttest{ # Stacked density plots: if you want to create a stacked density plot, you # probably want to 'count' (density * n) variable instead of the default From 71900e019f5de4ac777051115b953c1da610668b Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 12 Jul 2022 18:03:22 +0300 Subject: [PATCH 5/8] Use `cli::cli_warn()` instead of `warn()`. --- R/stat-density.r | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/stat-density.r b/R/stat-density.r index 30a11c2d75..b00a44ccbe 100644 --- a/R/stat-density.r +++ b/R/stat-density.r @@ -167,7 +167,7 @@ fit_data_to_bounds <- function(bounds, x, w) { is_inside_bounds <- (bounds[1] <= x) & (x <= bounds[2]) if (any(!is_inside_bounds)) { - warn("Some data points are outside of `bounds`. Removing them.") + cli::cli_warn("Some data points are outside of `bounds`. Removing them.") x <- x[is_inside_bounds] w <- w[is_inside_bounds] w_sum <- sum(w) From 5a625f701d7089c0736eae8b1e123b609cd9583e Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 12 Jul 2022 19:07:13 +0300 Subject: [PATCH 6/8] Add tests for `stat_density()`. --- tests/testthat/_snaps/stat-density.md | 2076 +++++++++++++++++++++++++ tests/testthat/test-stat-density.R | 51 + 2 files changed, 2127 insertions(+) diff --git a/tests/testthat/_snaps/stat-density.md b/tests/testthat/_snaps/stat-density.md index ef29bcb937..5b9b557064 100644 --- a/tests/testthat/_snaps/stat-density.md +++ b/tests/testthat/_snaps/stat-density.md @@ -1,3 +1,2079 @@ +# stat_density uses `bounds` + + Code + make_density(c(-Inf, Inf)) + Output + x y + 1 10.40000 0.01922476 + 2 10.44599 0.01951519 + 3 10.49198 0.01980689 + 4 10.53796 0.02010390 + 5 10.58395 0.02040182 + 6 10.62994 0.02070509 + 7 10.67593 0.02100983 + 8 10.72192 0.02131910 + 9 10.76791 0.02163082 + 10 10.81389 0.02194622 + 11 10.85988 0.02226510 + 12 10.90587 0.02258674 + 13 10.95186 0.02291293 + 14 10.99785 0.02324094 + 15 11.04384 0.02357458 + 16 11.08982 0.02390922 + 17 11.13581 0.02425023 + 18 11.18180 0.02459246 + 19 11.22779 0.02494008 + 20 11.27378 0.02528997 + 21 11.31977 0.02564424 + 22 11.36575 0.02600184 + 23 11.41174 0.02636279 + 24 11.45773 0.02672812 + 25 11.50372 0.02709575 + 26 11.54971 0.02746880 + 27 11.59569 0.02784309 + 28 11.64168 0.02822380 + 29 11.68767 0.02860553 + 30 11.73366 0.02899298 + 31 11.77965 0.02938225 + 32 11.82564 0.02977614 + 33 11.87162 0.03017279 + 34 11.91761 0.03057298 + 35 11.96360 0.03097683 + 36 12.00959 0.03138316 + 37 12.05558 0.03179397 + 38 12.10157 0.03220624 + 39 12.14755 0.03262371 + 40 12.19354 0.03304206 + 41 12.23953 0.03346550 + 42 12.28552 0.03389010 + 43 12.33151 0.03431870 + 44 12.37750 0.03474914 + 45 12.42348 0.03518258 + 46 12.46947 0.03561843 + 47 12.51546 0.03605634 + 48 12.56145 0.03649710 + 49 12.60744 0.03693911 + 50 12.65342 0.03738424 + 51 12.69941 0.03782995 + 52 12.74540 0.03827885 + 53 12.79139 0.03872821 + 54 12.83738 0.03917986 + 55 12.88337 0.03963224 + 56 12.92935 0.04008614 + 57 12.97534 0.04054086 + 58 13.02133 0.04099649 + 59 13.06732 0.04145286 + 60 13.11331 0.04190965 + 61 13.15930 0.04236693 + 62 13.20528 0.04282434 + 63 13.25127 0.04328177 + 64 13.29726 0.04373913 + 65 13.34325 0.04419598 + 66 13.38924 0.04465252 + 67 13.43523 0.04510819 + 68 13.48121 0.04556309 + 69 13.52720 0.04601695 + 70 13.57319 0.04646940 + 71 13.61918 0.04692083 + 72 13.66517 0.04737001 + 73 13.71115 0.04781837 + 74 13.75714 0.04826345 + 75 13.80313 0.04870791 + 76 13.84912 0.04914828 + 77 13.89511 0.04958763 + 78 13.94110 0.05002306 + 79 13.98708 0.05045648 + 80 14.03307 0.05088637 + 81 14.07906 0.05131308 + 82 14.12505 0.05173684 + 83 14.17104 0.05215606 + 84 14.21703 0.05257311 + 85 14.26301 0.05298410 + 86 14.30900 0.05339387 + 87 14.35499 0.05379592 + 88 14.40098 0.05419667 + 89 14.44697 0.05459031 + 90 14.49295 0.05498128 + 91 14.53894 0.05536611 + 92 14.58493 0.05574669 + 93 14.63092 0.05612226 + 94 14.67691 0.05649185 + 95 14.72290 0.05685773 + 96 14.76888 0.05721581 + 97 14.81487 0.05757161 + 98 14.86086 0.05791769 + 99 14.90685 0.05826211 + 100 14.95284 0.05859671 + 101 14.99883 0.05892862 + 102 15.04481 0.05925218 + 103 15.09080 0.05957121 + 104 15.13679 0.05988348 + 105 15.18278 0.06018935 + 106 15.22877 0.06049013 + 107 15.27476 0.06078258 + 108 15.32074 0.06107170 + 109 15.36673 0.06135055 + 110 15.41272 0.06162755 + 111 15.45871 0.06189301 + 112 15.50470 0.06215626 + 113 15.55068 0.06240980 + 114 15.59667 0.06265925 + 115 15.64266 0.06290085 + 116 15.68865 0.06313650 + 117 15.73464 0.06336619 + 118 15.78063 0.06358810 + 119 15.82661 0.06380593 + 120 15.87260 0.06401420 + 121 15.91859 0.06422026 + 122 15.96458 0.06441504 + 123 16.01057 0.06460802 + 124 16.05656 0.06479097 + 125 16.10254 0.06497071 + 126 16.14853 0.06514235 + 127 16.19452 0.06530910 + 128 16.24051 0.06546965 + 129 16.28650 0.06562371 + 130 16.33249 0.06577339 + 131 16.37847 0.06591506 + 132 16.42446 0.06605413 + 133 16.47045 0.06618376 + 134 16.51644 0.06631180 + 135 16.56243 0.06643045 + 136 16.60841 0.06654691 + 137 16.65440 0.06665579 + 138 16.70039 0.06676105 + 139 16.74638 0.06686047 + 140 16.79237 0.06695495 + 141 16.83836 0.06704521 + 142 16.88434 0.06712932 + 143 16.93033 0.06721074 + 144 16.97632 0.06728489 + 145 17.02231 0.06735771 + 146 17.06830 0.06742238 + 147 17.11429 0.06748575 + 148 17.16027 0.06754252 + 149 17.20626 0.06759683 + 150 17.25225 0.06764600 + 151 17.29824 0.06769166 + 152 17.34423 0.06773352 + 153 17.39022 0.06777090 + 154 17.43620 0.06780572 + 155 17.48219 0.06783518 + 156 17.52818 0.06786324 + 157 17.57417 0.06788511 + 158 17.62016 0.06790599 + 159 17.66614 0.06792125 + 160 17.71213 0.06793492 + 161 17.75812 0.06794412 + 162 17.80411 0.06795085 + 163 17.85010 0.06795418 + 164 17.89609 0.06795422 + 165 17.94207 0.06795185 + 166 17.98806 0.06794540 + 167 18.03405 0.06793748 + 168 18.08004 0.06792473 + 169 18.12603 0.06791113 + 170 18.17202 0.06789246 + 171 18.21800 0.06787272 + 172 18.26399 0.06784881 + 173 18.30998 0.06782303 + 174 18.35597 0.06779393 + 175 18.40196 0.06776216 + 176 18.44795 0.06772790 + 177 18.49393 0.06769017 + 178 18.53992 0.06765076 + 179 18.58591 0.06760704 + 180 18.63190 0.06756247 + 181 18.67789 0.06751273 + 182 18.72387 0.06746217 + 183 18.76986 0.06740711 + 184 18.81585 0.06735043 + 185 18.86184 0.06729002 + 186 18.90783 0.06722710 + 187 18.95382 0.06716123 + 188 18.99980 0.06709193 + 189 19.04579 0.06702049 + 190 19.09178 0.06694463 + 191 19.13777 0.06686749 + 192 19.18376 0.06678489 + 193 19.22975 0.06670135 + 194 19.27573 0.06661233 + 195 19.32172 0.06652179 + 196 19.36771 0.06642658 + 197 19.41370 0.06632880 + 198 19.45969 0.06622721 + 199 19.50568 0.06612195 + 200 19.55166 0.06601380 + 201 19.59765 0.06590081 + 202 19.64364 0.06578590 + 203 19.68963 0.06566492 + 204 19.73562 0.06554285 + 205 19.78160 0.06541384 + 206 19.82759 0.06528346 + 207 19.87358 0.06514710 + 208 19.91957 0.06500817 + 209 19.96556 0.06486428 + 210 20.01155 0.06471654 + 211 20.05753 0.06456494 + 212 20.10352 0.06440815 + 213 20.14951 0.06424866 + 214 20.19550 0.06408262 + 215 20.24149 0.06391507 + 216 20.28748 0.06373956 + 217 20.33346 0.06356274 + 218 20.37945 0.06337864 + 219 20.42544 0.06319214 + 220 20.47143 0.06299957 + 221 20.51742 0.06280323 + 222 20.56341 0.06260209 + 223 20.60939 0.06239578 + 224 20.65538 0.06218600 + 225 20.70137 0.06196963 + 226 20.74736 0.06175113 + 227 20.79335 0.06152464 + 228 20.83933 0.06129678 + 229 20.88532 0.06106075 + 230 20.93131 0.06082275 + 231 20.97730 0.06057795 + 232 21.02329 0.06032981 + 233 21.06928 0.06007629 + 234 21.11526 0.05981808 + 235 21.16125 0.05955588 + 236 21.20724 0.05928770 + 237 21.25323 0.05901692 + 238 21.29922 0.05873890 + 239 21.34521 0.05845956 + 240 21.39119 0.05817197 + 241 21.43718 0.05788301 + 242 21.48317 0.05758725 + 243 21.52916 0.05728891 + 244 21.57515 0.05698518 + 245 21.62114 0.05667773 + 246 21.66712 0.05636625 + 247 21.71311 0.05604999 + 248 21.75910 0.05573100 + 249 21.80509 0.05540628 + 250 21.85108 0.05508006 + 251 21.89706 0.05474725 + 252 21.94305 0.05441339 + 253 21.98904 0.05407363 + 254 22.03503 0.05373221 + 255 22.08102 0.05338619 + 256 22.12701 0.05303767 + 257 22.17299 0.05268574 + 258 22.21898 0.05233062 + 259 22.26497 0.05197317 + 260 22.31096 0.05161195 + 261 22.35695 0.05124939 + 262 22.40294 0.05088263 + 263 22.44892 0.05051516 + 264 22.49491 0.05014364 + 265 22.54090 0.04977134 + 266 22.58689 0.04939600 + 267 22.63288 0.04901945 + 268 22.67886 0.04864077 + 269 22.72485 0.04826058 + 270 22.77084 0.04787901 + 271 22.81683 0.04749582 + 272 22.86282 0.04711184 + 273 22.90881 0.04672627 + 274 22.95479 0.04634037 + 275 23.00078 0.04595305 + 276 23.04677 0.04556558 + 277 23.09276 0.04517730 + 278 23.13875 0.04478889 + 279 23.18474 0.04440015 + 280 23.23072 0.04401143 + 281 23.27671 0.04362272 + 282 23.32270 0.04323433 + 283 23.36869 0.04284613 + 284 23.41468 0.04245870 + 285 23.46067 0.04207150 + 286 23.50665 0.04168565 + 287 23.55264 0.04130008 + 288 23.59863 0.04091625 + 289 23.64462 0.04053301 + 290 23.69061 0.04015156 + 291 23.73659 0.03977124 + 292 23.78258 0.03939260 + 293 23.82857 0.03901577 + 294 23.87456 0.03864037 + 295 23.92055 0.03826758 + 296 23.96654 0.03789583 + 297 24.01252 0.03752761 + 298 24.05851 0.03716004 + 299 24.10450 0.03679676 + 300 24.15049 0.03643437 + 301 24.19648 0.03607587 + 302 24.24247 0.03571914 + 303 24.28845 0.03536577 + 304 24.33444 0.03501514 + 305 24.38043 0.03466723 + 306 24.42642 0.03432310 + 307 24.47241 0.03398095 + 308 24.51840 0.03364373 + 309 24.56438 0.03330762 + 310 24.61037 0.03297765 + 311 24.65636 0.03264869 + 312 24.70235 0.03232546 + 313 24.74834 0.03200416 + 314 24.79432 0.03168770 + 315 24.84031 0.03137434 + 316 24.88630 0.03106487 + 317 24.93229 0.03075970 + 318 24.97828 0.03045741 + 319 25.02427 0.03016067 + 320 25.07025 0.02986571 + 321 25.11624 0.02957759 + 322 25.16223 0.02929065 + 323 25.20822 0.02901080 + 324 25.25421 0.02873269 + 325 25.30020 0.02846056 + 326 25.34618 0.02819142 + 327 25.39217 0.02792710 + 328 25.43816 0.02766704 + 329 25.48415 0.02741061 + 330 25.53014 0.02715972 + 331 25.57613 0.02691123 + 332 25.62211 0.02666957 + 333 25.66810 0.02642915 + 334 25.71409 0.02619667 + 335 25.76008 0.02596553 + 336 25.80607 0.02574108 + 337 25.85205 0.02551922 + 338 25.89804 0.02530279 + 339 25.94403 0.02509021 + 340 25.99002 0.02488179 + 341 26.03601 0.02467846 + 342 26.08200 0.02447802 + 343 26.12798 0.02428390 + 344 26.17397 0.02409140 + 345 26.21996 0.02390642 + 346 26.26595 0.02372267 + 347 26.31194 0.02354591 + 348 26.35793 0.02337120 + 349 26.40391 0.02320220 + 350 26.44990 0.02303645 + 351 26.49589 0.02287513 + 352 26.54188 0.02271822 + 353 26.58787 0.02256450 + 354 26.63386 0.02241631 + 355 26.67984 0.02227009 + 356 26.72583 0.02213048 + 357 26.77182 0.02199203 + 358 26.81781 0.02186050 + 359 26.86380 0.02173045 + 360 26.90978 0.02160609 + 361 26.95577 0.02148429 + 362 27.00176 0.02136697 + 363 27.04775 0.02125324 + 364 27.09374 0.02114283 + 365 27.13973 0.02103700 + 366 27.18571 0.02093337 + 367 27.23170 0.02083525 + 368 27.27769 0.02073824 + 369 27.32368 0.02064764 + 370 27.36967 0.02055803 + 371 27.41566 0.02047381 + 372 27.46164 0.02039146 + 373 27.50763 0.02031339 + 374 27.55362 0.02023809 + 375 27.59961 0.02016600 + 376 27.64560 0.02009751 + 377 27.69159 0.02003123 + 378 27.73757 0.01996931 + 379 27.78356 0.01990865 + 380 27.82955 0.01985307 + 381 27.87554 0.01979832 + 382 27.92153 0.01974835 + 383 27.96751 0.01969961 + 384 28.01350 0.01965468 + 385 28.05949 0.01961170 + 386 28.10548 0.01957161 + 387 28.15147 0.01953411 + 388 28.19746 0.01949864 + 389 28.24344 0.01946633 + 390 28.28943 0.01943527 + 391 28.33542 0.01940786 + 392 28.38141 0.01938111 + 393 28.42740 0.01935818 + 394 28.47339 0.01933596 + 395 28.51937 0.01931675 + 396 28.56536 0.01929875 + 397 28.61135 0.01928302 + 398 28.65734 0.01926891 + 399 28.70333 0.01925642 + 400 28.74932 0.01924589 + 401 28.79530 0.01923638 + 402 28.84129 0.01922910 + 403 28.88728 0.01922231 + 404 28.93327 0.01921793 + 405 28.97926 0.01921391 + 406 29.02524 0.01921180 + 407 29.07123 0.01921025 + 408 29.11722 0.01921009 + 409 29.16321 0.01921066 + 410 29.20920 0.01921217 + 411 29.25519 0.01921452 + 412 29.30117 0.01921743 + 413 29.34716 0.01922120 + 414 29.39315 0.01922524 + 415 29.43914 0.01923006 + 416 29.48513 0.01923500 + 417 29.53112 0.01924047 + 418 29.57710 0.01924602 + 419 29.62309 0.01925181 + 420 29.66908 0.01925761 + 421 29.71507 0.01926343 + 422 29.76106 0.01926913 + 423 29.80705 0.01927472 + 424 29.85303 0.01927995 + 425 29.89902 0.01928504 + 426 29.94501 0.01928947 + 427 29.99100 0.01929377 + 428 30.03699 0.01929706 + 429 30.08297 0.01930013 + 430 30.12896 0.01930212 + 431 30.17495 0.01930362 + 432 30.22094 0.01930408 + 433 30.26693 0.01930369 + 434 30.31292 0.01930236 + 435 30.35890 0.01929975 + 436 30.40489 0.01929641 + 437 30.45088 0.01929127 + 438 30.49687 0.01928568 + 439 30.54286 0.01927772 + 440 30.58885 0.01926936 + 441 30.63483 0.01925860 + 442 30.68082 0.01924707 + 443 30.72681 0.01923342 + 444 30.77280 0.01921846 + 445 30.81879 0.01920172 + 446 30.86477 0.01918309 + 447 30.91076 0.01916308 + 448 30.95675 0.01914053 + 449 31.00274 0.01911708 + 450 31.04873 0.01909041 + 451 31.09472 0.01906317 + 452 31.14070 0.01903236 + 453 31.18669 0.01900075 + 454 31.23268 0.01896606 + 455 31.27867 0.01892991 + 456 31.32466 0.01889120 + 457 31.37065 0.01885035 + 458 31.41663 0.01880753 + 459 31.46262 0.01876184 + 460 31.50861 0.01871480 + 461 31.55460 0.01866417 + 462 31.60059 0.01861282 + 463 31.64658 0.01855714 + 464 31.69256 0.01850077 + 465 31.73855 0.01844062 + 466 31.78454 0.01837911 + 467 31.83053 0.01831449 + 468 31.87652 0.01824779 + 469 31.92250 0.01817867 + 470 31.96849 0.01810676 + 471 32.01448 0.01803312 + 472 32.06047 0.01795598 + 473 32.10646 0.01787783 + 474 32.15245 0.01779548 + 475 32.19843 0.01771242 + 476 32.24442 0.01762527 + 477 32.29041 0.01753704 + 478 32.33640 0.01744545 + 479 32.38239 0.01735210 + 480 32.42838 0.01725612 + 481 32.47436 0.01715771 + 482 32.52035 0.01705740 + 483 32.56634 0.01695404 + 484 32.61233 0.01684947 + 485 32.65832 0.01674126 + 486 32.70431 0.01663240 + 487 32.75029 0.01651959 + 488 32.79628 0.01640604 + 489 32.84227 0.01628927 + 490 32.88826 0.01617117 + 491 32.93425 0.01605056 + 492 32.98023 0.01592808 + 493 33.02622 0.01580375 + 494 33.07221 0.01567707 + 495 33.11820 0.01554916 + 496 33.16419 0.01541847 + 497 33.21018 0.01528714 + 498 33.25616 0.01515262 + 499 33.30215 0.01501762 + 500 33.34814 0.01487991 + 501 33.39413 0.01474137 + 502 33.44012 0.01460072 + 503 33.48611 0.01445886 + 504 33.53209 0.01431546 + 505 33.57808 0.01417052 + 506 33.62407 0.01402455 + 507 33.67006 0.01387677 + 508 33.71605 0.01372842 + 509 33.76204 0.01357807 + 510 33.80802 0.01342739 + 511 33.85401 0.01327487 + 512 33.90000 0.01312194 + +--- + + Code + make_density(c(mpg_min, Inf)) + Output + x y + 1 10.40000 0.03845214 + 2 10.44599 0.03845598 + 3 10.49198 0.03846380 + 4 10.53796 0.03847855 + 5 10.58395 0.03850133 + 6 10.62994 0.03852762 + 7 10.67593 0.03856114 + 8 10.72192 0.03859957 + 9 10.76791 0.03864387 + 10 10.81389 0.03869712 + 11 10.85988 0.03875358 + 12 10.90587 0.03881660 + 13 10.95186 0.03888567 + 14 10.99785 0.03895953 + 15 11.04384 0.03904294 + 16 11.08982 0.03912938 + 17 11.13581 0.03922177 + 18 11.18180 0.03932129 + 19 11.22779 0.03942492 + 20 11.27378 0.03953769 + 21 11.31977 0.03965393 + 22 11.36575 0.03977543 + 23 11.41174 0.03990500 + 24 11.45773 0.04003842 + 25 11.50372 0.04017964 + 26 11.54971 0.04032529 + 27 11.59569 0.04047540 + 28 11.64168 0.04063437 + 29 11.68767 0.04079685 + 30 11.73366 0.04096586 + 31 11.77965 0.04114024 + 32 11.82564 0.04131825 + 33 11.87162 0.04150552 + 34 11.91761 0.04169604 + 35 11.96360 0.04189187 + 36 12.00959 0.04209387 + 37 12.05558 0.04229917 + 38 12.10157 0.04251278 + 39 12.14755 0.04272990 + 40 12.19354 0.04295119 + 41 12.23953 0.04317921 + 42 12.28552 0.04341038 + 43 12.33151 0.04364825 + 44 12.37750 0.04389009 + 45 12.42348 0.04413500 + 46 12.46947 0.04438689 + 47 12.51546 0.04464163 + 48 12.56145 0.04490157 + 49 12.60744 0.04516572 + 50 12.65342 0.04543212 + 51 12.69941 0.04570492 + 52 12.74540 0.04598040 + 53 12.79139 0.04625971 + 54 12.83738 0.04654325 + 55 12.88337 0.04682867 + 56 12.92935 0.04711866 + 57 12.97534 0.04741152 + 58 13.02133 0.04770703 + 59 13.06732 0.04800650 + 60 13.11331 0.04830735 + 61 13.15930 0.04861086 + 62 13.20528 0.04891730 + 63 13.25127 0.04922543 + 64 13.29726 0.04953688 + 65 13.34325 0.04984900 + 66 13.38924 0.05016200 + 67 13.43523 0.05047785 + 68 13.48121 0.05079488 + 69 13.52720 0.05111376 + 70 13.57319 0.05143256 + 71 13.61918 0.05175075 + 72 13.66517 0.05207155 + 73 13.71115 0.05239297 + 74 13.75714 0.05271480 + 75 13.80313 0.05303543 + 76 13.84912 0.05335451 + 77 13.89511 0.05367573 + 78 13.94110 0.05399682 + 79 13.98708 0.05431705 + 80 14.03307 0.05463465 + 81 14.07906 0.05495052 + 82 14.12505 0.05526732 + 83 14.17104 0.05558333 + 84 14.21703 0.05589747 + 85 14.26301 0.05620742 + 86 14.30900 0.05651578 + 87 14.35499 0.05682375 + 88 14.40098 0.05713003 + 89 14.44697 0.05743379 + 90 14.49295 0.05773177 + 91 14.53894 0.05802833 + 92 14.58493 0.05832358 + 93 14.63092 0.05861582 + 94 14.67691 0.05890528 + 95 14.72290 0.05918741 + 96 14.76888 0.05946834 + 97 14.81487 0.05974734 + 98 14.86086 0.06002176 + 99 14.90685 0.06029351 + 100 14.95284 0.06055645 + 101 14.99883 0.06081847 + 102 15.04481 0.06107825 + 103 15.09080 0.06133165 + 104 15.13679 0.06158188 + 105 15.18278 0.06182400 + 106 15.22877 0.06206446 + 107 15.27476 0.06230264 + 108 15.32074 0.06253254 + 109 15.36673 0.06275909 + 110 15.41272 0.06297852 + 111 15.45871 0.06319548 + 112 15.50470 0.06341042 + 113 15.55068 0.06361503 + 114 15.59667 0.06381652 + 115 15.64266 0.06401204 + 116 15.68865 0.06420429 + 117 15.73464 0.06439420 + 118 15.78063 0.06457334 + 119 15.82661 0.06474917 + 120 15.87260 0.06492023 + 121 15.91859 0.06508726 + 122 15.96458 0.06525120 + 123 16.01057 0.06540525 + 124 16.05656 0.06555551 + 125 16.10254 0.06570217 + 126 16.14853 0.06584414 + 127 16.19452 0.06598234 + 128 16.24051 0.06611180 + 129 16.28650 0.06623720 + 130 16.33249 0.06636015 + 131 16.37847 0.06647770 + 132 16.42446 0.06659097 + 133 16.47045 0.06669684 + 134 16.51644 0.06679857 + 135 16.56243 0.06689820 + 136 16.60841 0.06699316 + 137 16.65440 0.06708280 + 138 16.70039 0.06716644 + 139 16.74638 0.06724604 + 140 16.79237 0.06732379 + 141 16.83836 0.06739761 + 142 16.88434 0.06746523 + 143 16.93033 0.06752830 + 144 16.97632 0.06758747 + 145 17.02231 0.06764491 + 146 17.06830 0.06769904 + 147 17.11429 0.06774651 + 148 17.16027 0.06779072 + 149 17.20626 0.06783139 + 150 17.25225 0.06787014 + 151 17.29824 0.06790610 + 152 17.34423 0.06793535 + 153 17.39022 0.06796230 + 154 17.43620 0.06798634 + 155 17.48219 0.06800801 + 156 17.52818 0.06802742 + 157 17.57417 0.06804021 + 158 17.62016 0.06805140 + 159 17.66614 0.06806022 + 160 17.71213 0.06806624 + 161 17.75812 0.06807055 + 162 17.80411 0.06806829 + 163 17.85010 0.06795336 + 164 17.89609 0.06795409 + 165 17.94207 0.06795131 + 166 17.98806 0.06794663 + 167 18.03405 0.06793625 + 168 18.08004 0.06792426 + 169 18.12603 0.06791038 + 170 18.17202 0.06789255 + 171 18.21800 0.06787277 + 172 18.26399 0.06784837 + 173 18.30998 0.06782205 + 174 18.35597 0.06779427 + 175 18.40196 0.06776197 + 176 18.44795 0.06772771 + 177 18.49393 0.06768963 + 178 18.53992 0.06764932 + 179 18.58591 0.06760770 + 180 18.63190 0.06756120 + 181 18.67789 0.06751255 + 182 18.72387 0.06746073 + 183 18.76986 0.06740627 + 184 18.81585 0.06735025 + 185 18.86184 0.06728952 + 186 18.90783 0.06722610 + 187 18.95382 0.06716007 + 188 18.99980 0.06709088 + 189 19.04579 0.06701978 + 190 19.09178 0.06694410 + 191 19.13777 0.06686513 + 192 19.18376 0.06678406 + 193 19.22975 0.06669922 + 194 19.27573 0.06661197 + 195 19.32172 0.06652030 + 196 19.36771 0.06642467 + 197 19.41370 0.06632713 + 198 19.45969 0.06622578 + 199 19.50568 0.06612103 + 200 19.55166 0.06601210 + 201 19.59765 0.06589852 + 202 19.64364 0.06578308 + 203 19.68963 0.06566400 + 204 19.73562 0.06554024 + 205 19.78160 0.06541265 + 206 19.82759 0.06527974 + 207 19.87358 0.06514499 + 208 19.91957 0.06500682 + 209 19.96556 0.06486247 + 210 20.01155 0.06471472 + 211 20.05753 0.06456125 + 212 20.10352 0.06440580 + 213 20.14951 0.06424724 + 214 20.19550 0.06408081 + 215 20.24149 0.06391113 + 216 20.28748 0.06373639 + 217 20.33346 0.06355900 + 218 20.37945 0.06337890 + 219 20.42544 0.06318912 + 220 20.47143 0.06299648 + 221 20.51742 0.06279950 + 222 20.56341 0.06259901 + 223 20.60939 0.06239615 + 224 20.65538 0.06218237 + 225 20.70137 0.06196630 + 226 20.74736 0.06174642 + 227 20.79335 0.06152209 + 228 20.83933 0.06129511 + 229 20.88532 0.06105778 + 230 20.93131 0.06081799 + 231 20.97730 0.06057499 + 232 21.02329 0.06032655 + 233 21.06928 0.06007497 + 234 21.11526 0.05981461 + 235 21.16125 0.05955125 + 236 21.20724 0.05928530 + 237 21.25323 0.05901300 + 238 21.29922 0.05873735 + 239 21.34521 0.05845451 + 240 21.39119 0.05816824 + 241 21.43718 0.05787999 + 242 21.48317 0.05758470 + 243 21.52916 0.05728606 + 244 21.57515 0.05698180 + 245 21.62114 0.05667382 + 246 21.66712 0.05636377 + 247 21.71311 0.05604756 + 248 21.75910 0.05572758 + 249 21.80509 0.05540346 + 250 21.85108 0.05507548 + 251 21.89706 0.05474540 + 252 21.94305 0.05441016 + 253 21.98904 0.05407102 + 254 22.03503 0.05372907 + 255 22.08102 0.05338331 + 256 22.12701 0.05303547 + 257 22.17299 0.05268356 + 258 22.21898 0.05232794 + 259 22.26497 0.05197043 + 260 22.31096 0.05160972 + 261 22.35695 0.05124688 + 262 22.40294 0.05088107 + 263 22.44892 0.05051203 + 264 22.49491 0.05014169 + 265 22.54090 0.04976912 + 266 22.58689 0.04939444 + 267 22.63288 0.04901784 + 268 22.67886 0.04863873 + 269 22.72485 0.04825883 + 270 22.77084 0.04787753 + 271 22.81683 0.04749450 + 272 22.86282 0.04711043 + 273 22.90881 0.04672481 + 274 22.95479 0.04633880 + 275 23.00078 0.04595210 + 276 23.04677 0.04556441 + 277 23.09276 0.04517632 + 278 23.13875 0.04478786 + 279 23.18474 0.04439928 + 280 23.23072 0.04401057 + 281 23.27671 0.04362202 + 282 23.32270 0.04323363 + 283 23.36869 0.04284573 + 284 23.41468 0.04245815 + 285 23.46067 0.04207082 + 286 23.50665 0.04168518 + 287 23.55264 0.04130012 + 288 23.59863 0.04091610 + 289 23.64462 0.04053298 + 290 23.69061 0.04015044 + 291 23.73659 0.03977124 + 292 23.78258 0.03939293 + 293 23.82857 0.03901593 + 294 23.87456 0.03864058 + 295 23.92055 0.03826641 + 296 23.96654 0.03789658 + 297 24.01252 0.03752816 + 298 24.05851 0.03716111 + 299 24.10450 0.03679671 + 300 24.15049 0.03643417 + 301 24.19648 0.03607632 + 302 24.24247 0.03572053 + 303 24.28845 0.03536606 + 304 24.33444 0.03501541 + 305 24.38043 0.03466729 + 306 24.42642 0.03432379 + 307 24.47241 0.03398307 + 308 24.51840 0.03364385 + 309 24.56438 0.03330903 + 310 24.61037 0.03297766 + 311 24.65636 0.03265054 + 312 24.70235 0.03232695 + 313 24.74834 0.03200518 + 314 24.79432 0.03168798 + 315 24.84031 0.03137526 + 316 24.88630 0.03106617 + 317 24.93229 0.03076136 + 318 24.97828 0.03045876 + 319 25.02427 0.03016069 + 320 25.07025 0.02986805 + 321 25.11624 0.02957839 + 322 25.16223 0.02929353 + 323 25.20822 0.02901141 + 324 25.25421 0.02873359 + 325 25.30020 0.02846205 + 326 25.34618 0.02819317 + 327 25.39217 0.02792873 + 328 25.43816 0.02766804 + 329 25.48415 0.02741122 + 330 25.53014 0.02716141 + 331 25.57613 0.02691392 + 332 25.62211 0.02667042 + 333 25.66810 0.02643176 + 334 25.71409 0.02619636 + 335 25.76008 0.02596855 + 336 25.80607 0.02574274 + 337 25.85205 0.02552043 + 338 25.89804 0.02530404 + 339 25.94403 0.02509069 + 340 25.99002 0.02488434 + 341 26.03601 0.02468024 + 342 26.08200 0.02447907 + 343 26.12798 0.02428492 + 344 26.17397 0.02409369 + 345 26.21996 0.02390830 + 346 26.26595 0.02372566 + 347 26.31194 0.02354538 + 348 26.35793 0.02337318 + 349 26.40391 0.02320361 + 350 26.44990 0.02303878 + 351 26.49589 0.02287714 + 352 26.54188 0.02271737 + 353 26.58787 0.02256654 + 354 26.63386 0.02241795 + 355 26.67984 0.02227310 + 356 26.72583 0.02213183 + 357 26.77182 0.02199280 + 358 26.81781 0.02186177 + 359 26.86380 0.02173334 + 360 26.90978 0.02160773 + 361 26.95577 0.02148603 + 362 27.00176 0.02136695 + 363 27.04775 0.02125487 + 364 27.09374 0.02114561 + 365 27.13973 0.02103838 + 366 27.18571 0.02093532 + 367 27.23170 0.02083524 + 368 27.27769 0.02074112 + 369 27.32368 0.02064992 + 370 27.36967 0.02056030 + 371 27.41566 0.02047474 + 372 27.46164 0.02039260 + 373 27.50763 0.02031517 + 374 27.55362 0.02024078 + 375 27.59961 0.02016787 + 376 27.64560 0.02009856 + 377 27.69159 0.02003304 + 378 27.73757 0.01997098 + 379 27.78356 0.01991208 + 380 27.82955 0.01985465 + 381 27.87554 0.01980028 + 382 27.92153 0.01974991 + 383 27.96751 0.01970192 + 384 28.01350 0.01965712 + 385 28.05949 0.01961378 + 386 28.10548 0.01957296 + 387 28.15147 0.01953613 + 388 28.19746 0.01950107 + 389 28.24344 0.01946859 + 390 28.28943 0.01943782 + 391 28.33542 0.01940902 + 392 28.38141 0.01938404 + 393 28.42740 0.01936032 + 394 28.47339 0.01933858 + 395 28.51937 0.01931873 + 396 28.56536 0.01930031 + 397 28.61135 0.01928536 + 398 28.65734 0.01927128 + 399 28.70333 0.01925863 + 400 28.74932 0.01924791 + 401 28.79530 0.01923824 + 402 28.84129 0.01923131 + 403 28.88728 0.01922504 + 404 28.93327 0.01921975 + 405 28.97926 0.01921625 + 406 29.02524 0.01921356 + 407 29.07123 0.01921260 + 408 29.11722 0.01921225 + 409 29.16321 0.01921249 + 410 29.20920 0.01921420 + 411 29.25519 0.01921642 + 412 29.30117 0.01921958 + 413 29.34716 0.01922318 + 414 29.39315 0.01922707 + 415 29.43914 0.01923191 + 416 29.48513 0.01923695 + 417 29.53112 0.01924231 + 418 29.57710 0.01924787 + 419 29.62309 0.01925352 + 420 29.66908 0.01925935 + 421 29.71507 0.01926511 + 422 29.76106 0.01927077 + 423 29.80705 0.01927629 + 424 29.85303 0.01928165 + 425 29.89902 0.01928649 + 426 29.94501 0.01929092 + 427 29.99100 0.01929501 + 428 30.03699 0.01929852 + 429 30.08297 0.01930154 + 430 30.12896 0.01930349 + 431 30.17495 0.01930462 + 432 30.22094 0.01930530 + 433 30.26693 0.01930494 + 434 30.31292 0.01930365 + 435 30.35890 0.01930090 + 436 30.40489 0.01929689 + 437 30.45088 0.01929230 + 438 30.49687 0.01928644 + 439 30.54286 0.01927896 + 440 30.58885 0.01926983 + 441 30.63483 0.01925902 + 442 30.68082 0.01924751 + 443 30.72681 0.01923460 + 444 30.77280 0.01921923 + 445 30.81879 0.01920221 + 446 30.86477 0.01918310 + 447 30.91076 0.01916315 + 448 30.95675 0.01914168 + 449 31.00274 0.01911698 + 450 31.04873 0.01909073 + 451 31.09472 0.01906222 + 452 31.14070 0.01903252 + 453 31.18669 0.01900126 + 454 31.23268 0.01896605 + 455 31.27867 0.01892941 + 456 31.32466 0.01889058 + 457 31.37065 0.01885004 + 458 31.41663 0.01880804 + 459 31.46262 0.01876140 + 460 31.50861 0.01871351 + 461 31.55460 0.01866360 + 462 31.60059 0.01861140 + 463 31.64658 0.01855789 + 464 31.69256 0.01849926 + 465 31.73855 0.01843954 + 466 31.78454 0.01837801 + 467 31.83053 0.01831361 + 468 31.87652 0.01824765 + 469 31.92250 0.01817718 + 470 31.96849 0.01810530 + 471 32.01448 0.01803190 + 472 32.06047 0.01795502 + 473 32.10646 0.01787646 + 474 32.15245 0.01779407 + 475 32.19843 0.01770999 + 476 32.24442 0.01762469 + 477 32.29041 0.01753534 + 478 32.33640 0.01744433 + 479 32.38239 0.01735019 + 480 32.42838 0.01725411 + 481 32.47436 0.01715692 + 482 32.52035 0.01705562 + 483 32.56634 0.01695257 + 484 32.61233 0.01684709 + 485 32.65832 0.01673947 + 486 32.70431 0.01663062 + 487 32.75029 0.01651816 + 488 32.79628 0.01640373 + 489 32.84227 0.01628752 + 490 32.88826 0.01616907 + 491 32.93425 0.01604927 + 492 32.98023 0.01592641 + 493 33.02622 0.01580152 + 494 33.07221 0.01567540 + 495 33.11820 0.01554700 + 496 33.16419 0.01541719 + 497 33.21018 0.01528492 + 498 33.25616 0.01515064 + 499 33.30215 0.01501542 + 500 33.34814 0.01487837 + 501 33.39413 0.01473969 + 502 33.44012 0.01459914 + 503 33.48611 0.01445674 + 504 33.53209 0.01431362 + 505 33.57808 0.01416910 + 506 33.62407 0.01402287 + 507 33.67006 0.01387533 + 508 33.71605 0.01372619 + 509 33.76204 0.01357651 + 510 33.80802 0.01342584 + 511 33.85401 0.01327351 + 512 33.90000 0.01312032 + +--- + + Code + make_density(c(-Inf, mpg_max)) + Output + x y + 1 10.40000 0.01922607 + 2 10.44599 0.01951572 + 3 10.49198 0.01980789 + 4 10.53796 0.02010489 + 5 10.58395 0.02040455 + 6 10.62994 0.02070565 + 7 10.67593 0.02101099 + 8 10.72192 0.02131954 + 9 10.76791 0.02163230 + 10 10.81389 0.02194827 + 11 10.85988 0.02226590 + 12 10.90587 0.02258777 + 13 10.95186 0.02291365 + 14 10.99785 0.02324302 + 15 11.04384 0.02357619 + 16 11.08982 0.02391129 + 17 11.13581 0.02425046 + 18 11.18180 0.02459440 + 19 11.22779 0.02494107 + 20 11.27378 0.02529202 + 21 11.31977 0.02564523 + 22 11.36575 0.02600221 + 23 11.41174 0.02636458 + 24 11.45773 0.02672930 + 25 11.50372 0.02709788 + 26 11.54971 0.02746948 + 27 11.59569 0.02784438 + 28 11.64168 0.02822509 + 29 11.68767 0.02860778 + 30 11.73366 0.02899380 + 31 11.77965 0.02938356 + 32 11.82564 0.02977602 + 33 11.87162 0.03017445 + 34 11.91761 0.03057448 + 35 11.96360 0.03097727 + 36 12.00959 0.03138436 + 37 12.05558 0.03179373 + 38 12.10157 0.03220837 + 39 12.14755 0.03262454 + 40 12.19354 0.03304285 + 41 12.23953 0.03346580 + 42 12.28552 0.03389072 + 43 12.33151 0.03431953 + 44 12.37750 0.03475001 + 45 12.42348 0.03518202 + 46 12.46947 0.03561862 + 47 12.51546 0.03605671 + 48 12.56145 0.03649743 + 49 12.60744 0.03693974 + 50 12.65342 0.03738301 + 51 12.69941 0.03783036 + 52 12.74540 0.03827861 + 53 12.79139 0.03872837 + 54 12.83738 0.03917945 + 55 12.88337 0.03963126 + 56 12.92935 0.04008553 + 57 12.97534 0.04054034 + 58 13.02133 0.04099578 + 59 13.06732 0.04145199 + 60 13.11331 0.04190854 + 61 13.15930 0.04236587 + 62 13.20528 0.04282319 + 63 13.25127 0.04328051 + 64 13.29726 0.04373778 + 65 13.34325 0.04419473 + 66 13.38924 0.04465092 + 67 13.43523 0.04510635 + 68 13.48121 0.04556137 + 69 13.52720 0.04601535 + 70 13.57319 0.04646798 + 71 13.61918 0.04691861 + 72 13.66517 0.04736759 + 73 13.71115 0.04781574 + 74 13.75714 0.04826189 + 75 13.80313 0.04870530 + 76 13.84912 0.04914604 + 77 13.89511 0.04958398 + 78 13.94110 0.05002061 + 79 13.98708 0.05045443 + 80 14.03307 0.05088381 + 81 14.07906 0.05131036 + 82 14.12505 0.05173279 + 83 14.17104 0.05215333 + 84 14.21703 0.05257047 + 85 14.26301 0.05298129 + 86 14.30900 0.05338916 + 87 14.35499 0.05379229 + 88 14.40098 0.05419243 + 89 14.44697 0.05458886 + 90 14.49295 0.05497703 + 91 14.53894 0.05536224 + 92 14.58493 0.05574259 + 93 14.63092 0.05611843 + 94 14.67691 0.05649059 + 95 14.72290 0.05685261 + 96 14.76888 0.05721183 + 97 14.81487 0.05756631 + 98 14.86086 0.05791455 + 99 14.90685 0.05825922 + 100 14.95284 0.05859255 + 101 14.99883 0.05892308 + 102 15.04481 0.05924925 + 103 15.09080 0.05956725 + 104 15.13679 0.05988117 + 105 15.18278 0.06018477 + 106 15.22877 0.06048466 + 107 15.27476 0.06078073 + 108 15.32074 0.06106667 + 109 15.36673 0.06134831 + 110 15.41272 0.06162095 + 111 15.45871 0.06188900 + 112 15.50470 0.06215393 + 113 15.55068 0.06240678 + 114 15.59667 0.06265545 + 115 15.64266 0.06289662 + 116 15.68865 0.06313239 + 117 15.73464 0.06336498 + 118 15.78063 0.06358537 + 119 15.82661 0.06380121 + 120 15.87260 0.06401108 + 121 15.91859 0.06421486 + 122 15.96458 0.06441490 + 123 16.01057 0.06460393 + 124 16.05656 0.06478777 + 125 16.10254 0.06496713 + 126 16.14853 0.06513985 + 127 16.19452 0.06530830 + 128 16.24051 0.06546715 + 129 16.28650 0.06562045 + 130 16.33249 0.06577056 + 131 16.37847 0.06591375 + 132 16.42446 0.06605214 + 133 16.47045 0.06618249 + 134 16.51644 0.06630715 + 135 16.56243 0.06642913 + 136 16.60841 0.06654530 + 137 16.65440 0.06665560 + 138 16.70039 0.06675946 + 139 16.74638 0.06685771 + 140 16.79237 0.06695366 + 141 16.83836 0.06704488 + 142 16.88434 0.06712934 + 143 16.93033 0.06720892 + 144 16.97632 0.06728313 + 145 17.02231 0.06735527 + 146 17.06830 0.06742355 + 147 17.11429 0.06748461 + 148 17.16027 0.06754207 + 149 17.20626 0.06759485 + 150 17.25225 0.06764537 + 151 17.29824 0.06769273 + 152 17.34423 0.06773286 + 153 17.39022 0.06777034 + 154 17.43620 0.06780404 + 155 17.48219 0.06783504 + 156 17.52818 0.06786356 + 157 17.57417 0.06788496 + 158 17.62016 0.06790443 + 159 17.66614 0.06792089 + 160 17.71213 0.06793424 + 161 17.75812 0.06794574 + 162 17.80411 0.06795025 + 163 17.85010 0.06795336 + 164 17.89609 0.06795409 + 165 17.94207 0.06795131 + 166 17.98806 0.06794663 + 167 18.03405 0.06793625 + 168 18.08004 0.06792426 + 169 18.12603 0.06791038 + 170 18.17202 0.06789255 + 171 18.21800 0.06787277 + 172 18.26399 0.06784837 + 173 18.30998 0.06782205 + 174 18.35597 0.06779427 + 175 18.40196 0.06776197 + 176 18.44795 0.06772771 + 177 18.49393 0.06768963 + 178 18.53992 0.06764932 + 179 18.58591 0.06760770 + 180 18.63190 0.06756120 + 181 18.67789 0.06751255 + 182 18.72387 0.06746073 + 183 18.76986 0.06740627 + 184 18.81585 0.06735025 + 185 18.86184 0.06728952 + 186 18.90783 0.06722610 + 187 18.95382 0.06716007 + 188 18.99980 0.06709088 + 189 19.04579 0.06701978 + 190 19.09178 0.06694410 + 191 19.13777 0.06686513 + 192 19.18376 0.06678406 + 193 19.22975 0.06669922 + 194 19.27573 0.06661197 + 195 19.32172 0.06652030 + 196 19.36771 0.06642467 + 197 19.41370 0.06632713 + 198 19.45969 0.06622578 + 199 19.50568 0.06612103 + 200 19.55166 0.06601210 + 201 19.59765 0.06589852 + 202 19.64364 0.06578308 + 203 19.68963 0.06566400 + 204 19.73562 0.06554024 + 205 19.78160 0.06541265 + 206 19.82759 0.06527974 + 207 19.87358 0.06514499 + 208 19.91957 0.06500682 + 209 19.96556 0.06486247 + 210 20.01155 0.06471472 + 211 20.05753 0.06456125 + 212 20.10352 0.06440580 + 213 20.14951 0.06424724 + 214 20.19550 0.06408081 + 215 20.24149 0.06391113 + 216 20.28748 0.06373639 + 217 20.33346 0.06355900 + 218 20.37945 0.06337890 + 219 20.42544 0.06318912 + 220 20.47143 0.06299648 + 221 20.51742 0.06279950 + 222 20.56341 0.06259901 + 223 20.60939 0.06239615 + 224 20.65538 0.06218237 + 225 20.70137 0.06196630 + 226 20.74736 0.06174642 + 227 20.79335 0.06152209 + 228 20.83933 0.06129511 + 229 20.88532 0.06105778 + 230 20.93131 0.06081799 + 231 20.97730 0.06057499 + 232 21.02329 0.06032655 + 233 21.06928 0.06007497 + 234 21.11526 0.05981461 + 235 21.16125 0.05955125 + 236 21.20724 0.05928530 + 237 21.25323 0.05901300 + 238 21.29922 0.05873735 + 239 21.34521 0.05845451 + 240 21.39119 0.05816824 + 241 21.43718 0.05787999 + 242 21.48317 0.05758470 + 243 21.52916 0.05728606 + 244 21.57515 0.05698180 + 245 21.62114 0.05667382 + 246 21.66712 0.05636377 + 247 21.71311 0.05604756 + 248 21.75910 0.05572758 + 249 21.80509 0.05540346 + 250 21.85108 0.05507548 + 251 21.89706 0.05474540 + 252 21.94305 0.05441016 + 253 21.98904 0.05407102 + 254 22.03503 0.05372907 + 255 22.08102 0.05338331 + 256 22.12701 0.05303547 + 257 22.17299 0.05268356 + 258 22.21898 0.05232794 + 259 22.26497 0.05197043 + 260 22.31096 0.05160972 + 261 22.35695 0.05124688 + 262 22.40294 0.05088107 + 263 22.44892 0.05051203 + 264 22.49491 0.05014169 + 265 22.54090 0.04976912 + 266 22.58689 0.04939444 + 267 22.63288 0.04901784 + 268 22.67886 0.04863873 + 269 22.72485 0.04825883 + 270 22.77084 0.04787753 + 271 22.81683 0.04749450 + 272 22.86282 0.04711043 + 273 22.90881 0.04672481 + 274 22.95479 0.04633880 + 275 23.00078 0.04595210 + 276 23.04677 0.04556441 + 277 23.09276 0.04517632 + 278 23.13875 0.04478786 + 279 23.18474 0.04439928 + 280 23.23072 0.04401057 + 281 23.27671 0.04362202 + 282 23.32270 0.04323363 + 283 23.36869 0.04284573 + 284 23.41468 0.04245815 + 285 23.46067 0.04207082 + 286 23.50665 0.04168518 + 287 23.55264 0.04130012 + 288 23.59863 0.04091610 + 289 23.64462 0.04053298 + 290 23.69061 0.04015044 + 291 23.73659 0.03977124 + 292 23.78258 0.03939293 + 293 23.82857 0.03901593 + 294 23.87456 0.03864058 + 295 23.92055 0.03826641 + 296 23.96654 0.03789658 + 297 24.01252 0.03752816 + 298 24.05851 0.03716111 + 299 24.10450 0.03679671 + 300 24.15049 0.03643417 + 301 24.19648 0.03607632 + 302 24.24247 0.03572053 + 303 24.28845 0.03536606 + 304 24.33444 0.03501541 + 305 24.38043 0.03466729 + 306 24.42642 0.03432379 + 307 24.47241 0.03398307 + 308 24.51840 0.03364385 + 309 24.56438 0.03330903 + 310 24.61037 0.03297766 + 311 24.65636 0.03265054 + 312 24.70235 0.03232695 + 313 24.74834 0.03200518 + 314 24.79432 0.03168798 + 315 24.84031 0.03137526 + 316 24.88630 0.03106617 + 317 24.93229 0.03076136 + 318 24.97828 0.03045876 + 319 25.02427 0.03016069 + 320 25.07025 0.02986805 + 321 25.11624 0.02957839 + 322 25.16223 0.02929353 + 323 25.20822 0.02901141 + 324 25.25421 0.02873359 + 325 25.30020 0.02846205 + 326 25.34618 0.02819317 + 327 25.39217 0.02792873 + 328 25.43816 0.02766804 + 329 25.48415 0.02741122 + 330 25.53014 0.02716141 + 331 25.57613 0.02691392 + 332 25.62211 0.02667042 + 333 25.66810 0.02643176 + 334 25.71409 0.02619636 + 335 25.76008 0.02596855 + 336 25.80607 0.02574274 + 337 25.85205 0.02552043 + 338 25.89804 0.02530404 + 339 25.94403 0.02509069 + 340 25.99002 0.02488434 + 341 26.03601 0.02468024 + 342 26.08200 0.02447907 + 343 26.12798 0.02428492 + 344 26.17397 0.02409369 + 345 26.21996 0.02390830 + 346 26.26595 0.02372566 + 347 26.31194 0.02354538 + 348 26.35793 0.02337318 + 349 26.40391 0.02320361 + 350 26.44990 0.02303878 + 351 26.49589 0.02294418 + 352 26.54188 0.02278834 + 353 26.58787 0.02264170 + 354 26.63386 0.02249740 + 355 26.67984 0.02235701 + 356 26.72583 0.02222059 + 357 26.77182 0.02208662 + 358 26.81781 0.02196095 + 359 26.86380 0.02183801 + 360 26.90978 0.02171810 + 361 26.95577 0.02160264 + 362 27.00176 0.02149000 + 363 27.04775 0.02138469 + 364 27.09374 0.02128242 + 365 27.13973 0.02118239 + 366 27.18571 0.02108725 + 367 27.23170 0.02099531 + 368 27.27769 0.02090967 + 369 27.32368 0.02082729 + 370 27.36967 0.02074671 + 371 27.41566 0.02067112 + 372 27.46164 0.02059915 + 373 27.50763 0.02053226 + 374 27.55362 0.02046891 + 375 27.59961 0.02040733 + 376 27.64560 0.02035035 + 377 27.69159 0.02029745 + 378 27.73757 0.02024837 + 379 27.78356 0.02020317 + 380 27.82955 0.02015982 + 381 27.87554 0.02012056 + 382 27.92153 0.02008570 + 383 27.96751 0.02005356 + 384 28.01350 0.02002562 + 385 28.05949 0.01999962 + 386 28.10548 0.01997713 + 387 28.15147 0.01995921 + 388 28.19746 0.01994338 + 389 28.24344 0.01993143 + 390 28.28943 0.01992179 + 391 28.33542 0.01991506 + 392 28.38141 0.01991291 + 393 28.42740 0.01991246 + 394 28.47339 0.01991540 + 395 28.51937 0.01992104 + 396 28.56536 0.01992897 + 397 28.61135 0.01994135 + 398 28.65734 0.01995519 + 399 28.70333 0.01997193 + 400 28.74932 0.01999167 + 401 28.79530 0.02001320 + 402 28.84129 0.02003870 + 403 28.88728 0.02006565 + 404 28.93327 0.02009506 + 405 28.97926 0.02012761 + 406 29.02524 0.02016165 + 407 29.07123 0.02019876 + 408 29.11722 0.02023758 + 409 29.16321 0.02027844 + 410 29.20920 0.02032242 + 411 29.25519 0.02036757 + 412 29.30117 0.02041495 + 413 29.34716 0.02046435 + 414 29.39315 0.02051541 + 415 29.43914 0.02056932 + 416 29.48513 0.02062409 + 417 29.53112 0.02068042 + 418 29.57710 0.02073907 + 419 29.62309 0.02079902 + 420 29.66908 0.02086128 + 421 29.71507 0.02092416 + 422 29.76106 0.02098809 + 423 29.80705 0.02105459 + 424 29.85303 0.02112213 + 425 29.89902 0.02119108 + 426 29.94501 0.02126054 + 427 29.99100 0.02133068 + 428 30.03699 0.02140364 + 429 30.08297 0.02147720 + 430 30.12896 0.02155137 + 431 30.17495 0.02162593 + 432 30.22094 0.02170092 + 433 30.26693 0.02177891 + 434 30.31292 0.02185685 + 435 30.35890 0.02193479 + 436 30.40489 0.02201306 + 437 30.45088 0.02209169 + 438 30.49687 0.02217308 + 439 30.54286 0.02225376 + 440 30.58885 0.02233405 + 441 30.63483 0.02241462 + 442 30.68082 0.02249569 + 443 30.72681 0.02257887 + 444 30.77280 0.02266074 + 445 30.81879 0.02274200 + 446 30.86477 0.02282355 + 447 30.91076 0.02290559 + 448 30.95675 0.02298909 + 449 31.00274 0.02307071 + 450 31.04873 0.02315159 + 451 31.09472 0.02323301 + 452 31.14070 0.02331460 + 453 31.18669 0.02339707 + 454 31.23268 0.02347711 + 455 31.27867 0.02355658 + 456 31.32466 0.02363646 + 457 31.37065 0.02371624 + 458 31.41663 0.02379644 + 459 31.46262 0.02387367 + 460 31.50861 0.02395057 + 461 31.55460 0.02402774 + 462 31.60059 0.02410441 + 463 31.64658 0.02418113 + 464 31.69256 0.02425449 + 465 31.73855 0.02432772 + 466 31.78454 0.02440110 + 467 31.83053 0.02447344 + 468 31.87652 0.02454519 + 469 31.92250 0.02461409 + 470 31.96849 0.02468264 + 471 32.01448 0.02475122 + 472 32.06047 0.02481811 + 473 32.10646 0.02488406 + 474 32.15245 0.02494748 + 475 32.19843 0.02501039 + 476 32.24442 0.02507325 + 477 32.29041 0.02513368 + 478 32.33640 0.02519299 + 479 32.38239 0.02525012 + 480 32.42838 0.02530653 + 481 32.47436 0.02536260 + 482 32.52035 0.02541593 + 483 32.56634 0.02546787 + 484 32.61233 0.02551802 + 485 32.65832 0.02556714 + 486 32.70431 0.02561553 + 487 32.75029 0.02566116 + 488 32.79628 0.02570513 + 489 32.84227 0.02574768 + 490 32.88826 0.02578879 + 491 32.93425 0.02582884 + 492 32.98023 0.02586619 + 493 33.02622 0.02590170 + 494 33.07221 0.02593614 + 495 33.11820 0.02596863 + 496 33.16419 0.02599975 + 497 33.21018 0.02602842 + 498 33.25616 0.02605508 + 499 33.30215 0.02608080 + 500 33.34814 0.02610434 + 501 33.39413 0.02612612 + 502 33.44012 0.02614579 + 503 33.48611 0.02616334 + 504 33.53209 0.02617995 + 505 33.57808 0.02619419 + 506 33.62407 0.02620636 + 507 33.67006 0.02621684 + 508 33.71605 0.02622507 + 509 33.76204 0.02623224 + 510 33.80802 0.02623701 + 511 33.85401 0.02623948 + 512 33.90000 0.02624065 + +--- + + Code + make_density(c(mpg_min, mpg_max)) + Output + x y + 1 10.40000 0.03845214 + 2 10.44599 0.03845598 + 3 10.49198 0.03846380 + 4 10.53796 0.03847855 + 5 10.58395 0.03850133 + 6 10.62994 0.03852762 + 7 10.67593 0.03856114 + 8 10.72192 0.03859957 + 9 10.76791 0.03864387 + 10 10.81389 0.03869712 + 11 10.85988 0.03875358 + 12 10.90587 0.03881660 + 13 10.95186 0.03888567 + 14 10.99785 0.03895953 + 15 11.04384 0.03904294 + 16 11.08982 0.03912938 + 17 11.13581 0.03922177 + 18 11.18180 0.03932129 + 19 11.22779 0.03942492 + 20 11.27378 0.03953769 + 21 11.31977 0.03965393 + 22 11.36575 0.03977543 + 23 11.41174 0.03990500 + 24 11.45773 0.04003842 + 25 11.50372 0.04017964 + 26 11.54971 0.04032529 + 27 11.59569 0.04047540 + 28 11.64168 0.04063437 + 29 11.68767 0.04079685 + 30 11.73366 0.04096586 + 31 11.77965 0.04114024 + 32 11.82564 0.04131825 + 33 11.87162 0.04150552 + 34 11.91761 0.04169604 + 35 11.96360 0.04189187 + 36 12.00959 0.04209387 + 37 12.05558 0.04229917 + 38 12.10157 0.04251278 + 39 12.14755 0.04272990 + 40 12.19354 0.04295119 + 41 12.23953 0.04317921 + 42 12.28552 0.04341038 + 43 12.33151 0.04364825 + 44 12.37750 0.04389009 + 45 12.42348 0.04413500 + 46 12.46947 0.04438689 + 47 12.51546 0.04464163 + 48 12.56145 0.04490157 + 49 12.60744 0.04516572 + 50 12.65342 0.04543212 + 51 12.69941 0.04570492 + 52 12.74540 0.04598040 + 53 12.79139 0.04625971 + 54 12.83738 0.04654325 + 55 12.88337 0.04682867 + 56 12.92935 0.04711866 + 57 12.97534 0.04741152 + 58 13.02133 0.04770703 + 59 13.06732 0.04800650 + 60 13.11331 0.04830735 + 61 13.15930 0.04861086 + 62 13.20528 0.04891730 + 63 13.25127 0.04922543 + 64 13.29726 0.04953688 + 65 13.34325 0.04984900 + 66 13.38924 0.05016200 + 67 13.43523 0.05047785 + 68 13.48121 0.05079488 + 69 13.52720 0.05111376 + 70 13.57319 0.05143256 + 71 13.61918 0.05175075 + 72 13.66517 0.05207155 + 73 13.71115 0.05239297 + 74 13.75714 0.05271480 + 75 13.80313 0.05303543 + 76 13.84912 0.05335451 + 77 13.89511 0.05367573 + 78 13.94110 0.05399682 + 79 13.98708 0.05431705 + 80 14.03307 0.05463465 + 81 14.07906 0.05495052 + 82 14.12505 0.05526732 + 83 14.17104 0.05558333 + 84 14.21703 0.05589747 + 85 14.26301 0.05620742 + 86 14.30900 0.05651578 + 87 14.35499 0.05682375 + 88 14.40098 0.05713003 + 89 14.44697 0.05743379 + 90 14.49295 0.05773177 + 91 14.53894 0.05802833 + 92 14.58493 0.05832358 + 93 14.63092 0.05861582 + 94 14.67691 0.05890528 + 95 14.72290 0.05918741 + 96 14.76888 0.05946834 + 97 14.81487 0.05974734 + 98 14.86086 0.06002176 + 99 14.90685 0.06029351 + 100 14.95284 0.06055645 + 101 14.99883 0.06081847 + 102 15.04481 0.06107825 + 103 15.09080 0.06133165 + 104 15.13679 0.06158188 + 105 15.18278 0.06182400 + 106 15.22877 0.06206446 + 107 15.27476 0.06230264 + 108 15.32074 0.06253254 + 109 15.36673 0.06275909 + 110 15.41272 0.06297852 + 111 15.45871 0.06319548 + 112 15.50470 0.06341042 + 113 15.55068 0.06361503 + 114 15.59667 0.06381652 + 115 15.64266 0.06401204 + 116 15.68865 0.06420429 + 117 15.73464 0.06439420 + 118 15.78063 0.06457334 + 119 15.82661 0.06474917 + 120 15.87260 0.06492023 + 121 15.91859 0.06508726 + 122 15.96458 0.06525120 + 123 16.01057 0.06540525 + 124 16.05656 0.06555551 + 125 16.10254 0.06570217 + 126 16.14853 0.06584414 + 127 16.19452 0.06598234 + 128 16.24051 0.06611180 + 129 16.28650 0.06623720 + 130 16.33249 0.06636015 + 131 16.37847 0.06647770 + 132 16.42446 0.06659097 + 133 16.47045 0.06669684 + 134 16.51644 0.06679857 + 135 16.56243 0.06689820 + 136 16.60841 0.06699316 + 137 16.65440 0.06708280 + 138 16.70039 0.06716644 + 139 16.74638 0.06724604 + 140 16.79237 0.06732379 + 141 16.83836 0.06739761 + 142 16.88434 0.06746523 + 143 16.93033 0.06752830 + 144 16.97632 0.06758747 + 145 17.02231 0.06764491 + 146 17.06830 0.06769904 + 147 17.11429 0.06774651 + 148 17.16027 0.06779072 + 149 17.20626 0.06783139 + 150 17.25225 0.06787014 + 151 17.29824 0.06790610 + 152 17.34423 0.06793535 + 153 17.39022 0.06796230 + 154 17.43620 0.06798634 + 155 17.48219 0.06800801 + 156 17.52818 0.06802742 + 157 17.57417 0.06804021 + 158 17.62016 0.06805140 + 159 17.66614 0.06806022 + 160 17.71213 0.06806624 + 161 17.75812 0.06807055 + 162 17.80411 0.06806829 + 163 17.85010 0.06795336 + 164 17.89609 0.06795409 + 165 17.94207 0.06795131 + 166 17.98806 0.06794663 + 167 18.03405 0.06793625 + 168 18.08004 0.06792426 + 169 18.12603 0.06791038 + 170 18.17202 0.06789255 + 171 18.21800 0.06787277 + 172 18.26399 0.06784837 + 173 18.30998 0.06782205 + 174 18.35597 0.06779427 + 175 18.40196 0.06776197 + 176 18.44795 0.06772771 + 177 18.49393 0.06768963 + 178 18.53992 0.06764932 + 179 18.58591 0.06760770 + 180 18.63190 0.06756120 + 181 18.67789 0.06751255 + 182 18.72387 0.06746073 + 183 18.76986 0.06740627 + 184 18.81585 0.06735025 + 185 18.86184 0.06728952 + 186 18.90783 0.06722610 + 187 18.95382 0.06716007 + 188 18.99980 0.06709088 + 189 19.04579 0.06701978 + 190 19.09178 0.06694410 + 191 19.13777 0.06686513 + 192 19.18376 0.06678406 + 193 19.22975 0.06669922 + 194 19.27573 0.06661197 + 195 19.32172 0.06652030 + 196 19.36771 0.06642467 + 197 19.41370 0.06632713 + 198 19.45969 0.06622578 + 199 19.50568 0.06612103 + 200 19.55166 0.06601210 + 201 19.59765 0.06589852 + 202 19.64364 0.06578308 + 203 19.68963 0.06566400 + 204 19.73562 0.06554024 + 205 19.78160 0.06541265 + 206 19.82759 0.06527974 + 207 19.87358 0.06514499 + 208 19.91957 0.06500682 + 209 19.96556 0.06486247 + 210 20.01155 0.06471472 + 211 20.05753 0.06456125 + 212 20.10352 0.06440580 + 213 20.14951 0.06424724 + 214 20.19550 0.06408081 + 215 20.24149 0.06391113 + 216 20.28748 0.06373639 + 217 20.33346 0.06355900 + 218 20.37945 0.06337890 + 219 20.42544 0.06318912 + 220 20.47143 0.06299648 + 221 20.51742 0.06279950 + 222 20.56341 0.06259901 + 223 20.60939 0.06239615 + 224 20.65538 0.06218237 + 225 20.70137 0.06196630 + 226 20.74736 0.06174642 + 227 20.79335 0.06152209 + 228 20.83933 0.06129511 + 229 20.88532 0.06105778 + 230 20.93131 0.06081799 + 231 20.97730 0.06057499 + 232 21.02329 0.06032655 + 233 21.06928 0.06007497 + 234 21.11526 0.05981461 + 235 21.16125 0.05955125 + 236 21.20724 0.05928530 + 237 21.25323 0.05901300 + 238 21.29922 0.05873735 + 239 21.34521 0.05845451 + 240 21.39119 0.05816824 + 241 21.43718 0.05787999 + 242 21.48317 0.05758470 + 243 21.52916 0.05728606 + 244 21.57515 0.05698180 + 245 21.62114 0.05667382 + 246 21.66712 0.05636377 + 247 21.71311 0.05604756 + 248 21.75910 0.05572758 + 249 21.80509 0.05540346 + 250 21.85108 0.05507548 + 251 21.89706 0.05474540 + 252 21.94305 0.05441016 + 253 21.98904 0.05407102 + 254 22.03503 0.05372907 + 255 22.08102 0.05338331 + 256 22.12701 0.05303547 + 257 22.17299 0.05268356 + 258 22.21898 0.05232794 + 259 22.26497 0.05197043 + 260 22.31096 0.05160972 + 261 22.35695 0.05124688 + 262 22.40294 0.05088107 + 263 22.44892 0.05051203 + 264 22.49491 0.05014169 + 265 22.54090 0.04976912 + 266 22.58689 0.04939444 + 267 22.63288 0.04901784 + 268 22.67886 0.04863873 + 269 22.72485 0.04825883 + 270 22.77084 0.04787753 + 271 22.81683 0.04749450 + 272 22.86282 0.04711043 + 273 22.90881 0.04672481 + 274 22.95479 0.04633880 + 275 23.00078 0.04595210 + 276 23.04677 0.04556441 + 277 23.09276 0.04517632 + 278 23.13875 0.04478786 + 279 23.18474 0.04439928 + 280 23.23072 0.04401057 + 281 23.27671 0.04362202 + 282 23.32270 0.04323363 + 283 23.36869 0.04284573 + 284 23.41468 0.04245815 + 285 23.46067 0.04207082 + 286 23.50665 0.04168518 + 287 23.55264 0.04130012 + 288 23.59863 0.04091610 + 289 23.64462 0.04053298 + 290 23.69061 0.04015044 + 291 23.73659 0.03977124 + 292 23.78258 0.03939293 + 293 23.82857 0.03901593 + 294 23.87456 0.03864058 + 295 23.92055 0.03826641 + 296 23.96654 0.03789658 + 297 24.01252 0.03752816 + 298 24.05851 0.03716111 + 299 24.10450 0.03679671 + 300 24.15049 0.03643417 + 301 24.19648 0.03607632 + 302 24.24247 0.03572053 + 303 24.28845 0.03536606 + 304 24.33444 0.03501541 + 305 24.38043 0.03466729 + 306 24.42642 0.03432379 + 307 24.47241 0.03398307 + 308 24.51840 0.03364385 + 309 24.56438 0.03330903 + 310 24.61037 0.03297766 + 311 24.65636 0.03265054 + 312 24.70235 0.03232695 + 313 24.74834 0.03200518 + 314 24.79432 0.03168798 + 315 24.84031 0.03137526 + 316 24.88630 0.03106617 + 317 24.93229 0.03076136 + 318 24.97828 0.03045876 + 319 25.02427 0.03016069 + 320 25.07025 0.02986805 + 321 25.11624 0.02957839 + 322 25.16223 0.02929353 + 323 25.20822 0.02901141 + 324 25.25421 0.02873359 + 325 25.30020 0.02846205 + 326 25.34618 0.02819317 + 327 25.39217 0.02792873 + 328 25.43816 0.02766804 + 329 25.48415 0.02741122 + 330 25.53014 0.02716141 + 331 25.57613 0.02691392 + 332 25.62211 0.02667042 + 333 25.66810 0.02643176 + 334 25.71409 0.02619636 + 335 25.76008 0.02596855 + 336 25.80607 0.02574274 + 337 25.85205 0.02552043 + 338 25.89804 0.02530404 + 339 25.94403 0.02509069 + 340 25.99002 0.02488434 + 341 26.03601 0.02468024 + 342 26.08200 0.02447907 + 343 26.12798 0.02428492 + 344 26.17397 0.02409369 + 345 26.21996 0.02390830 + 346 26.26595 0.02372566 + 347 26.31194 0.02354538 + 348 26.35793 0.02337318 + 349 26.40391 0.02320361 + 350 26.44990 0.02303878 + 351 26.49589 0.02294418 + 352 26.54188 0.02278834 + 353 26.58787 0.02264170 + 354 26.63386 0.02249740 + 355 26.67984 0.02235701 + 356 26.72583 0.02222059 + 357 26.77182 0.02208662 + 358 26.81781 0.02196095 + 359 26.86380 0.02183801 + 360 26.90978 0.02171810 + 361 26.95577 0.02160264 + 362 27.00176 0.02149000 + 363 27.04775 0.02138469 + 364 27.09374 0.02128242 + 365 27.13973 0.02118239 + 366 27.18571 0.02108725 + 367 27.23170 0.02099531 + 368 27.27769 0.02090967 + 369 27.32368 0.02082729 + 370 27.36967 0.02074671 + 371 27.41566 0.02067112 + 372 27.46164 0.02059915 + 373 27.50763 0.02053226 + 374 27.55362 0.02046891 + 375 27.59961 0.02040733 + 376 27.64560 0.02035035 + 377 27.69159 0.02029745 + 378 27.73757 0.02024837 + 379 27.78356 0.02020317 + 380 27.82955 0.02015982 + 381 27.87554 0.02012056 + 382 27.92153 0.02008570 + 383 27.96751 0.02005356 + 384 28.01350 0.02002562 + 385 28.05949 0.01999962 + 386 28.10548 0.01997713 + 387 28.15147 0.01995921 + 388 28.19746 0.01994338 + 389 28.24344 0.01993143 + 390 28.28943 0.01992179 + 391 28.33542 0.01991506 + 392 28.38141 0.01991291 + 393 28.42740 0.01991246 + 394 28.47339 0.01991540 + 395 28.51937 0.01992104 + 396 28.56536 0.01992897 + 397 28.61135 0.01994135 + 398 28.65734 0.01995519 + 399 28.70333 0.01997193 + 400 28.74932 0.01999167 + 401 28.79530 0.02001320 + 402 28.84129 0.02003870 + 403 28.88728 0.02006565 + 404 28.93327 0.02009506 + 405 28.97926 0.02012761 + 406 29.02524 0.02016165 + 407 29.07123 0.02019876 + 408 29.11722 0.02023758 + 409 29.16321 0.02027844 + 410 29.20920 0.02032242 + 411 29.25519 0.02036757 + 412 29.30117 0.02041495 + 413 29.34716 0.02046435 + 414 29.39315 0.02051541 + 415 29.43914 0.02056932 + 416 29.48513 0.02062409 + 417 29.53112 0.02068042 + 418 29.57710 0.02073907 + 419 29.62309 0.02079902 + 420 29.66908 0.02086128 + 421 29.71507 0.02092416 + 422 29.76106 0.02098809 + 423 29.80705 0.02105459 + 424 29.85303 0.02112213 + 425 29.89902 0.02119108 + 426 29.94501 0.02126054 + 427 29.99100 0.02133068 + 428 30.03699 0.02140364 + 429 30.08297 0.02147720 + 430 30.12896 0.02155137 + 431 30.17495 0.02162593 + 432 30.22094 0.02170092 + 433 30.26693 0.02177891 + 434 30.31292 0.02185685 + 435 30.35890 0.02193479 + 436 30.40489 0.02201306 + 437 30.45088 0.02209169 + 438 30.49687 0.02217308 + 439 30.54286 0.02225376 + 440 30.58885 0.02233405 + 441 30.63483 0.02241462 + 442 30.68082 0.02249569 + 443 30.72681 0.02257887 + 444 30.77280 0.02266074 + 445 30.81879 0.02274200 + 446 30.86477 0.02282355 + 447 30.91076 0.02290559 + 448 30.95675 0.02298909 + 449 31.00274 0.02307071 + 450 31.04873 0.02315159 + 451 31.09472 0.02323301 + 452 31.14070 0.02331460 + 453 31.18669 0.02339707 + 454 31.23268 0.02347711 + 455 31.27867 0.02355658 + 456 31.32466 0.02363646 + 457 31.37065 0.02371624 + 458 31.41663 0.02379644 + 459 31.46262 0.02387367 + 460 31.50861 0.02395057 + 461 31.55460 0.02402774 + 462 31.60059 0.02410441 + 463 31.64658 0.02418113 + 464 31.69256 0.02425449 + 465 31.73855 0.02432772 + 466 31.78454 0.02440110 + 467 31.83053 0.02447344 + 468 31.87652 0.02454519 + 469 31.92250 0.02461409 + 470 31.96849 0.02468264 + 471 32.01448 0.02475122 + 472 32.06047 0.02481811 + 473 32.10646 0.02488406 + 474 32.15245 0.02494748 + 475 32.19843 0.02501039 + 476 32.24442 0.02507325 + 477 32.29041 0.02513368 + 478 32.33640 0.02519299 + 479 32.38239 0.02525012 + 480 32.42838 0.02530653 + 481 32.47436 0.02536260 + 482 32.52035 0.02541593 + 483 32.56634 0.02546787 + 484 32.61233 0.02551802 + 485 32.65832 0.02556714 + 486 32.70431 0.02561553 + 487 32.75029 0.02566116 + 488 32.79628 0.02570513 + 489 32.84227 0.02574768 + 490 32.88826 0.02578879 + 491 32.93425 0.02582884 + 492 32.98023 0.02586619 + 493 33.02622 0.02590170 + 494 33.07221 0.02593614 + 495 33.11820 0.02596863 + 496 33.16419 0.02599975 + 497 33.21018 0.02602842 + 498 33.25616 0.02605508 + 499 33.30215 0.02608080 + 500 33.34814 0.02610434 + 501 33.39413 0.02612612 + 502 33.44012 0.02614579 + 503 33.48611 0.02616334 + 504 33.53209 0.02617995 + 505 33.57808 0.02619419 + 506 33.62407 0.02620636 + 507 33.67006 0.02621684 + 508 33.71605 0.02622507 + 509 33.76204 0.02623224 + 510 33.80802 0.02623701 + 511 33.85401 0.02623948 + 512 33.90000 0.02624065 + # stat_density works in both directions Problem while computing stat. diff --git a/tests/testthat/test-stat-density.R b/tests/testthat/test-stat-density.R index a2cde72e5d..2e2af6d0c8 100644 --- a/tests/testthat/test-stat-density.R +++ b/tests/testthat/test-stat-density.R @@ -1,3 +1,54 @@ +test_that("stat_density actually computes density", { + # Compare functon approximations because outputs from `ggplot()` and + # `density()` give grids spanning different ranges + dens <- stats::density(mtcars$mpg) + expected_density_fun <- stats::approxfun(data.frame(x = dens$x, y = dens$y)) + + plot <- ggplot(mtcars, aes(mpg)) + stat_density() + actual_density_fun <- stats::approxfun(layer_data(plot)[, c("x", "y")]) + + test_sample <- unique(mtcars$mpg) + expect_equal( + expected_density_fun(test_sample), + actual_density_fun(test_sample), + tolerance = 1e-3 + ) +}) + +test_that("stat_density uses `bounds`", { + make_density <- function(bounds) { + plot <- ggplot(mtcars, aes(mpg)) + stat_density(bounds = bounds) + return(layer_data(plot)[, c("x", "y")]) + } + + mpg_min <- min(mtcars$mpg) + mpg_max <- max(mtcars$mpg) + + # Density should be around twice higher at finite boundary + expect_snapshot(make_density(c(-Inf, Inf))) + expect_snapshot(make_density(c(mpg_min, Inf))) + expect_snapshot(make_density(c(-Inf, mpg_max))) + expect_snapshot(make_density(c(mpg_min, mpg_max))) +}) + +test_that("stat_density handles data outside of `bounds`", { + cutoff <- mtcars$mpg[1] + + expect_warning( + data_actual <- layer_data( + ggplot(mtcars, aes(mpg)) + stat_density(bounds = c(cutoff, Inf)) + ), + "outside of `bounds`" + ) + + mtcars_filtered <- mtcars[mtcars$mpg >= cutoff, ] + data_expected <- layer_data( + ggplot(mtcars_filtered, aes(mpg)) + stat_density(bounds = c(cutoff, Inf)) + ) + + expect_equal(data_actual, data_expected) +}) + test_that("compute_density succeeds when variance is zero", { dens <- compute_density(rep(0, 10), NULL, from = 0.5, to = 0.5) expect_equal(dens$n, rep(10, 512)) From 57229b3620f0933af4919f53ae2b3dbfa51dae4d Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 12 Jul 2022 20:16:49 +0300 Subject: [PATCH 7/8] Update tests for `stat_density()`. --- R/stat-density.r | 2 + tests/testthat/_snaps/stat-density.md | 2076 ------------------------- tests/testthat/test-stat-density.R | 64 +- 3 files changed, 54 insertions(+), 2088 deletions(-) diff --git a/R/stat-density.r b/R/stat-density.r index b00a44ccbe..89e488041b 100644 --- a/R/stat-density.r +++ b/R/stat-density.r @@ -77,6 +77,8 @@ StatDensity <- ggproto("StatDensity", Stat, default_aes = aes(x = after_stat(density), y = after_stat(density), fill = NA, weight = NULL), + dropped_aes = "weight", + setup_params = function(self, data, params) { params$flipped_aes <- has_flipped_aes(data, params, main_is_orthogonal = FALSE, main_is_continuous = TRUE) diff --git a/tests/testthat/_snaps/stat-density.md b/tests/testthat/_snaps/stat-density.md index 5b9b557064..ef29bcb937 100644 --- a/tests/testthat/_snaps/stat-density.md +++ b/tests/testthat/_snaps/stat-density.md @@ -1,2079 +1,3 @@ -# stat_density uses `bounds` - - Code - make_density(c(-Inf, Inf)) - Output - x y - 1 10.40000 0.01922476 - 2 10.44599 0.01951519 - 3 10.49198 0.01980689 - 4 10.53796 0.02010390 - 5 10.58395 0.02040182 - 6 10.62994 0.02070509 - 7 10.67593 0.02100983 - 8 10.72192 0.02131910 - 9 10.76791 0.02163082 - 10 10.81389 0.02194622 - 11 10.85988 0.02226510 - 12 10.90587 0.02258674 - 13 10.95186 0.02291293 - 14 10.99785 0.02324094 - 15 11.04384 0.02357458 - 16 11.08982 0.02390922 - 17 11.13581 0.02425023 - 18 11.18180 0.02459246 - 19 11.22779 0.02494008 - 20 11.27378 0.02528997 - 21 11.31977 0.02564424 - 22 11.36575 0.02600184 - 23 11.41174 0.02636279 - 24 11.45773 0.02672812 - 25 11.50372 0.02709575 - 26 11.54971 0.02746880 - 27 11.59569 0.02784309 - 28 11.64168 0.02822380 - 29 11.68767 0.02860553 - 30 11.73366 0.02899298 - 31 11.77965 0.02938225 - 32 11.82564 0.02977614 - 33 11.87162 0.03017279 - 34 11.91761 0.03057298 - 35 11.96360 0.03097683 - 36 12.00959 0.03138316 - 37 12.05558 0.03179397 - 38 12.10157 0.03220624 - 39 12.14755 0.03262371 - 40 12.19354 0.03304206 - 41 12.23953 0.03346550 - 42 12.28552 0.03389010 - 43 12.33151 0.03431870 - 44 12.37750 0.03474914 - 45 12.42348 0.03518258 - 46 12.46947 0.03561843 - 47 12.51546 0.03605634 - 48 12.56145 0.03649710 - 49 12.60744 0.03693911 - 50 12.65342 0.03738424 - 51 12.69941 0.03782995 - 52 12.74540 0.03827885 - 53 12.79139 0.03872821 - 54 12.83738 0.03917986 - 55 12.88337 0.03963224 - 56 12.92935 0.04008614 - 57 12.97534 0.04054086 - 58 13.02133 0.04099649 - 59 13.06732 0.04145286 - 60 13.11331 0.04190965 - 61 13.15930 0.04236693 - 62 13.20528 0.04282434 - 63 13.25127 0.04328177 - 64 13.29726 0.04373913 - 65 13.34325 0.04419598 - 66 13.38924 0.04465252 - 67 13.43523 0.04510819 - 68 13.48121 0.04556309 - 69 13.52720 0.04601695 - 70 13.57319 0.04646940 - 71 13.61918 0.04692083 - 72 13.66517 0.04737001 - 73 13.71115 0.04781837 - 74 13.75714 0.04826345 - 75 13.80313 0.04870791 - 76 13.84912 0.04914828 - 77 13.89511 0.04958763 - 78 13.94110 0.05002306 - 79 13.98708 0.05045648 - 80 14.03307 0.05088637 - 81 14.07906 0.05131308 - 82 14.12505 0.05173684 - 83 14.17104 0.05215606 - 84 14.21703 0.05257311 - 85 14.26301 0.05298410 - 86 14.30900 0.05339387 - 87 14.35499 0.05379592 - 88 14.40098 0.05419667 - 89 14.44697 0.05459031 - 90 14.49295 0.05498128 - 91 14.53894 0.05536611 - 92 14.58493 0.05574669 - 93 14.63092 0.05612226 - 94 14.67691 0.05649185 - 95 14.72290 0.05685773 - 96 14.76888 0.05721581 - 97 14.81487 0.05757161 - 98 14.86086 0.05791769 - 99 14.90685 0.05826211 - 100 14.95284 0.05859671 - 101 14.99883 0.05892862 - 102 15.04481 0.05925218 - 103 15.09080 0.05957121 - 104 15.13679 0.05988348 - 105 15.18278 0.06018935 - 106 15.22877 0.06049013 - 107 15.27476 0.06078258 - 108 15.32074 0.06107170 - 109 15.36673 0.06135055 - 110 15.41272 0.06162755 - 111 15.45871 0.06189301 - 112 15.50470 0.06215626 - 113 15.55068 0.06240980 - 114 15.59667 0.06265925 - 115 15.64266 0.06290085 - 116 15.68865 0.06313650 - 117 15.73464 0.06336619 - 118 15.78063 0.06358810 - 119 15.82661 0.06380593 - 120 15.87260 0.06401420 - 121 15.91859 0.06422026 - 122 15.96458 0.06441504 - 123 16.01057 0.06460802 - 124 16.05656 0.06479097 - 125 16.10254 0.06497071 - 126 16.14853 0.06514235 - 127 16.19452 0.06530910 - 128 16.24051 0.06546965 - 129 16.28650 0.06562371 - 130 16.33249 0.06577339 - 131 16.37847 0.06591506 - 132 16.42446 0.06605413 - 133 16.47045 0.06618376 - 134 16.51644 0.06631180 - 135 16.56243 0.06643045 - 136 16.60841 0.06654691 - 137 16.65440 0.06665579 - 138 16.70039 0.06676105 - 139 16.74638 0.06686047 - 140 16.79237 0.06695495 - 141 16.83836 0.06704521 - 142 16.88434 0.06712932 - 143 16.93033 0.06721074 - 144 16.97632 0.06728489 - 145 17.02231 0.06735771 - 146 17.06830 0.06742238 - 147 17.11429 0.06748575 - 148 17.16027 0.06754252 - 149 17.20626 0.06759683 - 150 17.25225 0.06764600 - 151 17.29824 0.06769166 - 152 17.34423 0.06773352 - 153 17.39022 0.06777090 - 154 17.43620 0.06780572 - 155 17.48219 0.06783518 - 156 17.52818 0.06786324 - 157 17.57417 0.06788511 - 158 17.62016 0.06790599 - 159 17.66614 0.06792125 - 160 17.71213 0.06793492 - 161 17.75812 0.06794412 - 162 17.80411 0.06795085 - 163 17.85010 0.06795418 - 164 17.89609 0.06795422 - 165 17.94207 0.06795185 - 166 17.98806 0.06794540 - 167 18.03405 0.06793748 - 168 18.08004 0.06792473 - 169 18.12603 0.06791113 - 170 18.17202 0.06789246 - 171 18.21800 0.06787272 - 172 18.26399 0.06784881 - 173 18.30998 0.06782303 - 174 18.35597 0.06779393 - 175 18.40196 0.06776216 - 176 18.44795 0.06772790 - 177 18.49393 0.06769017 - 178 18.53992 0.06765076 - 179 18.58591 0.06760704 - 180 18.63190 0.06756247 - 181 18.67789 0.06751273 - 182 18.72387 0.06746217 - 183 18.76986 0.06740711 - 184 18.81585 0.06735043 - 185 18.86184 0.06729002 - 186 18.90783 0.06722710 - 187 18.95382 0.06716123 - 188 18.99980 0.06709193 - 189 19.04579 0.06702049 - 190 19.09178 0.06694463 - 191 19.13777 0.06686749 - 192 19.18376 0.06678489 - 193 19.22975 0.06670135 - 194 19.27573 0.06661233 - 195 19.32172 0.06652179 - 196 19.36771 0.06642658 - 197 19.41370 0.06632880 - 198 19.45969 0.06622721 - 199 19.50568 0.06612195 - 200 19.55166 0.06601380 - 201 19.59765 0.06590081 - 202 19.64364 0.06578590 - 203 19.68963 0.06566492 - 204 19.73562 0.06554285 - 205 19.78160 0.06541384 - 206 19.82759 0.06528346 - 207 19.87358 0.06514710 - 208 19.91957 0.06500817 - 209 19.96556 0.06486428 - 210 20.01155 0.06471654 - 211 20.05753 0.06456494 - 212 20.10352 0.06440815 - 213 20.14951 0.06424866 - 214 20.19550 0.06408262 - 215 20.24149 0.06391507 - 216 20.28748 0.06373956 - 217 20.33346 0.06356274 - 218 20.37945 0.06337864 - 219 20.42544 0.06319214 - 220 20.47143 0.06299957 - 221 20.51742 0.06280323 - 222 20.56341 0.06260209 - 223 20.60939 0.06239578 - 224 20.65538 0.06218600 - 225 20.70137 0.06196963 - 226 20.74736 0.06175113 - 227 20.79335 0.06152464 - 228 20.83933 0.06129678 - 229 20.88532 0.06106075 - 230 20.93131 0.06082275 - 231 20.97730 0.06057795 - 232 21.02329 0.06032981 - 233 21.06928 0.06007629 - 234 21.11526 0.05981808 - 235 21.16125 0.05955588 - 236 21.20724 0.05928770 - 237 21.25323 0.05901692 - 238 21.29922 0.05873890 - 239 21.34521 0.05845956 - 240 21.39119 0.05817197 - 241 21.43718 0.05788301 - 242 21.48317 0.05758725 - 243 21.52916 0.05728891 - 244 21.57515 0.05698518 - 245 21.62114 0.05667773 - 246 21.66712 0.05636625 - 247 21.71311 0.05604999 - 248 21.75910 0.05573100 - 249 21.80509 0.05540628 - 250 21.85108 0.05508006 - 251 21.89706 0.05474725 - 252 21.94305 0.05441339 - 253 21.98904 0.05407363 - 254 22.03503 0.05373221 - 255 22.08102 0.05338619 - 256 22.12701 0.05303767 - 257 22.17299 0.05268574 - 258 22.21898 0.05233062 - 259 22.26497 0.05197317 - 260 22.31096 0.05161195 - 261 22.35695 0.05124939 - 262 22.40294 0.05088263 - 263 22.44892 0.05051516 - 264 22.49491 0.05014364 - 265 22.54090 0.04977134 - 266 22.58689 0.04939600 - 267 22.63288 0.04901945 - 268 22.67886 0.04864077 - 269 22.72485 0.04826058 - 270 22.77084 0.04787901 - 271 22.81683 0.04749582 - 272 22.86282 0.04711184 - 273 22.90881 0.04672627 - 274 22.95479 0.04634037 - 275 23.00078 0.04595305 - 276 23.04677 0.04556558 - 277 23.09276 0.04517730 - 278 23.13875 0.04478889 - 279 23.18474 0.04440015 - 280 23.23072 0.04401143 - 281 23.27671 0.04362272 - 282 23.32270 0.04323433 - 283 23.36869 0.04284613 - 284 23.41468 0.04245870 - 285 23.46067 0.04207150 - 286 23.50665 0.04168565 - 287 23.55264 0.04130008 - 288 23.59863 0.04091625 - 289 23.64462 0.04053301 - 290 23.69061 0.04015156 - 291 23.73659 0.03977124 - 292 23.78258 0.03939260 - 293 23.82857 0.03901577 - 294 23.87456 0.03864037 - 295 23.92055 0.03826758 - 296 23.96654 0.03789583 - 297 24.01252 0.03752761 - 298 24.05851 0.03716004 - 299 24.10450 0.03679676 - 300 24.15049 0.03643437 - 301 24.19648 0.03607587 - 302 24.24247 0.03571914 - 303 24.28845 0.03536577 - 304 24.33444 0.03501514 - 305 24.38043 0.03466723 - 306 24.42642 0.03432310 - 307 24.47241 0.03398095 - 308 24.51840 0.03364373 - 309 24.56438 0.03330762 - 310 24.61037 0.03297765 - 311 24.65636 0.03264869 - 312 24.70235 0.03232546 - 313 24.74834 0.03200416 - 314 24.79432 0.03168770 - 315 24.84031 0.03137434 - 316 24.88630 0.03106487 - 317 24.93229 0.03075970 - 318 24.97828 0.03045741 - 319 25.02427 0.03016067 - 320 25.07025 0.02986571 - 321 25.11624 0.02957759 - 322 25.16223 0.02929065 - 323 25.20822 0.02901080 - 324 25.25421 0.02873269 - 325 25.30020 0.02846056 - 326 25.34618 0.02819142 - 327 25.39217 0.02792710 - 328 25.43816 0.02766704 - 329 25.48415 0.02741061 - 330 25.53014 0.02715972 - 331 25.57613 0.02691123 - 332 25.62211 0.02666957 - 333 25.66810 0.02642915 - 334 25.71409 0.02619667 - 335 25.76008 0.02596553 - 336 25.80607 0.02574108 - 337 25.85205 0.02551922 - 338 25.89804 0.02530279 - 339 25.94403 0.02509021 - 340 25.99002 0.02488179 - 341 26.03601 0.02467846 - 342 26.08200 0.02447802 - 343 26.12798 0.02428390 - 344 26.17397 0.02409140 - 345 26.21996 0.02390642 - 346 26.26595 0.02372267 - 347 26.31194 0.02354591 - 348 26.35793 0.02337120 - 349 26.40391 0.02320220 - 350 26.44990 0.02303645 - 351 26.49589 0.02287513 - 352 26.54188 0.02271822 - 353 26.58787 0.02256450 - 354 26.63386 0.02241631 - 355 26.67984 0.02227009 - 356 26.72583 0.02213048 - 357 26.77182 0.02199203 - 358 26.81781 0.02186050 - 359 26.86380 0.02173045 - 360 26.90978 0.02160609 - 361 26.95577 0.02148429 - 362 27.00176 0.02136697 - 363 27.04775 0.02125324 - 364 27.09374 0.02114283 - 365 27.13973 0.02103700 - 366 27.18571 0.02093337 - 367 27.23170 0.02083525 - 368 27.27769 0.02073824 - 369 27.32368 0.02064764 - 370 27.36967 0.02055803 - 371 27.41566 0.02047381 - 372 27.46164 0.02039146 - 373 27.50763 0.02031339 - 374 27.55362 0.02023809 - 375 27.59961 0.02016600 - 376 27.64560 0.02009751 - 377 27.69159 0.02003123 - 378 27.73757 0.01996931 - 379 27.78356 0.01990865 - 380 27.82955 0.01985307 - 381 27.87554 0.01979832 - 382 27.92153 0.01974835 - 383 27.96751 0.01969961 - 384 28.01350 0.01965468 - 385 28.05949 0.01961170 - 386 28.10548 0.01957161 - 387 28.15147 0.01953411 - 388 28.19746 0.01949864 - 389 28.24344 0.01946633 - 390 28.28943 0.01943527 - 391 28.33542 0.01940786 - 392 28.38141 0.01938111 - 393 28.42740 0.01935818 - 394 28.47339 0.01933596 - 395 28.51937 0.01931675 - 396 28.56536 0.01929875 - 397 28.61135 0.01928302 - 398 28.65734 0.01926891 - 399 28.70333 0.01925642 - 400 28.74932 0.01924589 - 401 28.79530 0.01923638 - 402 28.84129 0.01922910 - 403 28.88728 0.01922231 - 404 28.93327 0.01921793 - 405 28.97926 0.01921391 - 406 29.02524 0.01921180 - 407 29.07123 0.01921025 - 408 29.11722 0.01921009 - 409 29.16321 0.01921066 - 410 29.20920 0.01921217 - 411 29.25519 0.01921452 - 412 29.30117 0.01921743 - 413 29.34716 0.01922120 - 414 29.39315 0.01922524 - 415 29.43914 0.01923006 - 416 29.48513 0.01923500 - 417 29.53112 0.01924047 - 418 29.57710 0.01924602 - 419 29.62309 0.01925181 - 420 29.66908 0.01925761 - 421 29.71507 0.01926343 - 422 29.76106 0.01926913 - 423 29.80705 0.01927472 - 424 29.85303 0.01927995 - 425 29.89902 0.01928504 - 426 29.94501 0.01928947 - 427 29.99100 0.01929377 - 428 30.03699 0.01929706 - 429 30.08297 0.01930013 - 430 30.12896 0.01930212 - 431 30.17495 0.01930362 - 432 30.22094 0.01930408 - 433 30.26693 0.01930369 - 434 30.31292 0.01930236 - 435 30.35890 0.01929975 - 436 30.40489 0.01929641 - 437 30.45088 0.01929127 - 438 30.49687 0.01928568 - 439 30.54286 0.01927772 - 440 30.58885 0.01926936 - 441 30.63483 0.01925860 - 442 30.68082 0.01924707 - 443 30.72681 0.01923342 - 444 30.77280 0.01921846 - 445 30.81879 0.01920172 - 446 30.86477 0.01918309 - 447 30.91076 0.01916308 - 448 30.95675 0.01914053 - 449 31.00274 0.01911708 - 450 31.04873 0.01909041 - 451 31.09472 0.01906317 - 452 31.14070 0.01903236 - 453 31.18669 0.01900075 - 454 31.23268 0.01896606 - 455 31.27867 0.01892991 - 456 31.32466 0.01889120 - 457 31.37065 0.01885035 - 458 31.41663 0.01880753 - 459 31.46262 0.01876184 - 460 31.50861 0.01871480 - 461 31.55460 0.01866417 - 462 31.60059 0.01861282 - 463 31.64658 0.01855714 - 464 31.69256 0.01850077 - 465 31.73855 0.01844062 - 466 31.78454 0.01837911 - 467 31.83053 0.01831449 - 468 31.87652 0.01824779 - 469 31.92250 0.01817867 - 470 31.96849 0.01810676 - 471 32.01448 0.01803312 - 472 32.06047 0.01795598 - 473 32.10646 0.01787783 - 474 32.15245 0.01779548 - 475 32.19843 0.01771242 - 476 32.24442 0.01762527 - 477 32.29041 0.01753704 - 478 32.33640 0.01744545 - 479 32.38239 0.01735210 - 480 32.42838 0.01725612 - 481 32.47436 0.01715771 - 482 32.52035 0.01705740 - 483 32.56634 0.01695404 - 484 32.61233 0.01684947 - 485 32.65832 0.01674126 - 486 32.70431 0.01663240 - 487 32.75029 0.01651959 - 488 32.79628 0.01640604 - 489 32.84227 0.01628927 - 490 32.88826 0.01617117 - 491 32.93425 0.01605056 - 492 32.98023 0.01592808 - 493 33.02622 0.01580375 - 494 33.07221 0.01567707 - 495 33.11820 0.01554916 - 496 33.16419 0.01541847 - 497 33.21018 0.01528714 - 498 33.25616 0.01515262 - 499 33.30215 0.01501762 - 500 33.34814 0.01487991 - 501 33.39413 0.01474137 - 502 33.44012 0.01460072 - 503 33.48611 0.01445886 - 504 33.53209 0.01431546 - 505 33.57808 0.01417052 - 506 33.62407 0.01402455 - 507 33.67006 0.01387677 - 508 33.71605 0.01372842 - 509 33.76204 0.01357807 - 510 33.80802 0.01342739 - 511 33.85401 0.01327487 - 512 33.90000 0.01312194 - ---- - - Code - make_density(c(mpg_min, Inf)) - Output - x y - 1 10.40000 0.03845214 - 2 10.44599 0.03845598 - 3 10.49198 0.03846380 - 4 10.53796 0.03847855 - 5 10.58395 0.03850133 - 6 10.62994 0.03852762 - 7 10.67593 0.03856114 - 8 10.72192 0.03859957 - 9 10.76791 0.03864387 - 10 10.81389 0.03869712 - 11 10.85988 0.03875358 - 12 10.90587 0.03881660 - 13 10.95186 0.03888567 - 14 10.99785 0.03895953 - 15 11.04384 0.03904294 - 16 11.08982 0.03912938 - 17 11.13581 0.03922177 - 18 11.18180 0.03932129 - 19 11.22779 0.03942492 - 20 11.27378 0.03953769 - 21 11.31977 0.03965393 - 22 11.36575 0.03977543 - 23 11.41174 0.03990500 - 24 11.45773 0.04003842 - 25 11.50372 0.04017964 - 26 11.54971 0.04032529 - 27 11.59569 0.04047540 - 28 11.64168 0.04063437 - 29 11.68767 0.04079685 - 30 11.73366 0.04096586 - 31 11.77965 0.04114024 - 32 11.82564 0.04131825 - 33 11.87162 0.04150552 - 34 11.91761 0.04169604 - 35 11.96360 0.04189187 - 36 12.00959 0.04209387 - 37 12.05558 0.04229917 - 38 12.10157 0.04251278 - 39 12.14755 0.04272990 - 40 12.19354 0.04295119 - 41 12.23953 0.04317921 - 42 12.28552 0.04341038 - 43 12.33151 0.04364825 - 44 12.37750 0.04389009 - 45 12.42348 0.04413500 - 46 12.46947 0.04438689 - 47 12.51546 0.04464163 - 48 12.56145 0.04490157 - 49 12.60744 0.04516572 - 50 12.65342 0.04543212 - 51 12.69941 0.04570492 - 52 12.74540 0.04598040 - 53 12.79139 0.04625971 - 54 12.83738 0.04654325 - 55 12.88337 0.04682867 - 56 12.92935 0.04711866 - 57 12.97534 0.04741152 - 58 13.02133 0.04770703 - 59 13.06732 0.04800650 - 60 13.11331 0.04830735 - 61 13.15930 0.04861086 - 62 13.20528 0.04891730 - 63 13.25127 0.04922543 - 64 13.29726 0.04953688 - 65 13.34325 0.04984900 - 66 13.38924 0.05016200 - 67 13.43523 0.05047785 - 68 13.48121 0.05079488 - 69 13.52720 0.05111376 - 70 13.57319 0.05143256 - 71 13.61918 0.05175075 - 72 13.66517 0.05207155 - 73 13.71115 0.05239297 - 74 13.75714 0.05271480 - 75 13.80313 0.05303543 - 76 13.84912 0.05335451 - 77 13.89511 0.05367573 - 78 13.94110 0.05399682 - 79 13.98708 0.05431705 - 80 14.03307 0.05463465 - 81 14.07906 0.05495052 - 82 14.12505 0.05526732 - 83 14.17104 0.05558333 - 84 14.21703 0.05589747 - 85 14.26301 0.05620742 - 86 14.30900 0.05651578 - 87 14.35499 0.05682375 - 88 14.40098 0.05713003 - 89 14.44697 0.05743379 - 90 14.49295 0.05773177 - 91 14.53894 0.05802833 - 92 14.58493 0.05832358 - 93 14.63092 0.05861582 - 94 14.67691 0.05890528 - 95 14.72290 0.05918741 - 96 14.76888 0.05946834 - 97 14.81487 0.05974734 - 98 14.86086 0.06002176 - 99 14.90685 0.06029351 - 100 14.95284 0.06055645 - 101 14.99883 0.06081847 - 102 15.04481 0.06107825 - 103 15.09080 0.06133165 - 104 15.13679 0.06158188 - 105 15.18278 0.06182400 - 106 15.22877 0.06206446 - 107 15.27476 0.06230264 - 108 15.32074 0.06253254 - 109 15.36673 0.06275909 - 110 15.41272 0.06297852 - 111 15.45871 0.06319548 - 112 15.50470 0.06341042 - 113 15.55068 0.06361503 - 114 15.59667 0.06381652 - 115 15.64266 0.06401204 - 116 15.68865 0.06420429 - 117 15.73464 0.06439420 - 118 15.78063 0.06457334 - 119 15.82661 0.06474917 - 120 15.87260 0.06492023 - 121 15.91859 0.06508726 - 122 15.96458 0.06525120 - 123 16.01057 0.06540525 - 124 16.05656 0.06555551 - 125 16.10254 0.06570217 - 126 16.14853 0.06584414 - 127 16.19452 0.06598234 - 128 16.24051 0.06611180 - 129 16.28650 0.06623720 - 130 16.33249 0.06636015 - 131 16.37847 0.06647770 - 132 16.42446 0.06659097 - 133 16.47045 0.06669684 - 134 16.51644 0.06679857 - 135 16.56243 0.06689820 - 136 16.60841 0.06699316 - 137 16.65440 0.06708280 - 138 16.70039 0.06716644 - 139 16.74638 0.06724604 - 140 16.79237 0.06732379 - 141 16.83836 0.06739761 - 142 16.88434 0.06746523 - 143 16.93033 0.06752830 - 144 16.97632 0.06758747 - 145 17.02231 0.06764491 - 146 17.06830 0.06769904 - 147 17.11429 0.06774651 - 148 17.16027 0.06779072 - 149 17.20626 0.06783139 - 150 17.25225 0.06787014 - 151 17.29824 0.06790610 - 152 17.34423 0.06793535 - 153 17.39022 0.06796230 - 154 17.43620 0.06798634 - 155 17.48219 0.06800801 - 156 17.52818 0.06802742 - 157 17.57417 0.06804021 - 158 17.62016 0.06805140 - 159 17.66614 0.06806022 - 160 17.71213 0.06806624 - 161 17.75812 0.06807055 - 162 17.80411 0.06806829 - 163 17.85010 0.06795336 - 164 17.89609 0.06795409 - 165 17.94207 0.06795131 - 166 17.98806 0.06794663 - 167 18.03405 0.06793625 - 168 18.08004 0.06792426 - 169 18.12603 0.06791038 - 170 18.17202 0.06789255 - 171 18.21800 0.06787277 - 172 18.26399 0.06784837 - 173 18.30998 0.06782205 - 174 18.35597 0.06779427 - 175 18.40196 0.06776197 - 176 18.44795 0.06772771 - 177 18.49393 0.06768963 - 178 18.53992 0.06764932 - 179 18.58591 0.06760770 - 180 18.63190 0.06756120 - 181 18.67789 0.06751255 - 182 18.72387 0.06746073 - 183 18.76986 0.06740627 - 184 18.81585 0.06735025 - 185 18.86184 0.06728952 - 186 18.90783 0.06722610 - 187 18.95382 0.06716007 - 188 18.99980 0.06709088 - 189 19.04579 0.06701978 - 190 19.09178 0.06694410 - 191 19.13777 0.06686513 - 192 19.18376 0.06678406 - 193 19.22975 0.06669922 - 194 19.27573 0.06661197 - 195 19.32172 0.06652030 - 196 19.36771 0.06642467 - 197 19.41370 0.06632713 - 198 19.45969 0.06622578 - 199 19.50568 0.06612103 - 200 19.55166 0.06601210 - 201 19.59765 0.06589852 - 202 19.64364 0.06578308 - 203 19.68963 0.06566400 - 204 19.73562 0.06554024 - 205 19.78160 0.06541265 - 206 19.82759 0.06527974 - 207 19.87358 0.06514499 - 208 19.91957 0.06500682 - 209 19.96556 0.06486247 - 210 20.01155 0.06471472 - 211 20.05753 0.06456125 - 212 20.10352 0.06440580 - 213 20.14951 0.06424724 - 214 20.19550 0.06408081 - 215 20.24149 0.06391113 - 216 20.28748 0.06373639 - 217 20.33346 0.06355900 - 218 20.37945 0.06337890 - 219 20.42544 0.06318912 - 220 20.47143 0.06299648 - 221 20.51742 0.06279950 - 222 20.56341 0.06259901 - 223 20.60939 0.06239615 - 224 20.65538 0.06218237 - 225 20.70137 0.06196630 - 226 20.74736 0.06174642 - 227 20.79335 0.06152209 - 228 20.83933 0.06129511 - 229 20.88532 0.06105778 - 230 20.93131 0.06081799 - 231 20.97730 0.06057499 - 232 21.02329 0.06032655 - 233 21.06928 0.06007497 - 234 21.11526 0.05981461 - 235 21.16125 0.05955125 - 236 21.20724 0.05928530 - 237 21.25323 0.05901300 - 238 21.29922 0.05873735 - 239 21.34521 0.05845451 - 240 21.39119 0.05816824 - 241 21.43718 0.05787999 - 242 21.48317 0.05758470 - 243 21.52916 0.05728606 - 244 21.57515 0.05698180 - 245 21.62114 0.05667382 - 246 21.66712 0.05636377 - 247 21.71311 0.05604756 - 248 21.75910 0.05572758 - 249 21.80509 0.05540346 - 250 21.85108 0.05507548 - 251 21.89706 0.05474540 - 252 21.94305 0.05441016 - 253 21.98904 0.05407102 - 254 22.03503 0.05372907 - 255 22.08102 0.05338331 - 256 22.12701 0.05303547 - 257 22.17299 0.05268356 - 258 22.21898 0.05232794 - 259 22.26497 0.05197043 - 260 22.31096 0.05160972 - 261 22.35695 0.05124688 - 262 22.40294 0.05088107 - 263 22.44892 0.05051203 - 264 22.49491 0.05014169 - 265 22.54090 0.04976912 - 266 22.58689 0.04939444 - 267 22.63288 0.04901784 - 268 22.67886 0.04863873 - 269 22.72485 0.04825883 - 270 22.77084 0.04787753 - 271 22.81683 0.04749450 - 272 22.86282 0.04711043 - 273 22.90881 0.04672481 - 274 22.95479 0.04633880 - 275 23.00078 0.04595210 - 276 23.04677 0.04556441 - 277 23.09276 0.04517632 - 278 23.13875 0.04478786 - 279 23.18474 0.04439928 - 280 23.23072 0.04401057 - 281 23.27671 0.04362202 - 282 23.32270 0.04323363 - 283 23.36869 0.04284573 - 284 23.41468 0.04245815 - 285 23.46067 0.04207082 - 286 23.50665 0.04168518 - 287 23.55264 0.04130012 - 288 23.59863 0.04091610 - 289 23.64462 0.04053298 - 290 23.69061 0.04015044 - 291 23.73659 0.03977124 - 292 23.78258 0.03939293 - 293 23.82857 0.03901593 - 294 23.87456 0.03864058 - 295 23.92055 0.03826641 - 296 23.96654 0.03789658 - 297 24.01252 0.03752816 - 298 24.05851 0.03716111 - 299 24.10450 0.03679671 - 300 24.15049 0.03643417 - 301 24.19648 0.03607632 - 302 24.24247 0.03572053 - 303 24.28845 0.03536606 - 304 24.33444 0.03501541 - 305 24.38043 0.03466729 - 306 24.42642 0.03432379 - 307 24.47241 0.03398307 - 308 24.51840 0.03364385 - 309 24.56438 0.03330903 - 310 24.61037 0.03297766 - 311 24.65636 0.03265054 - 312 24.70235 0.03232695 - 313 24.74834 0.03200518 - 314 24.79432 0.03168798 - 315 24.84031 0.03137526 - 316 24.88630 0.03106617 - 317 24.93229 0.03076136 - 318 24.97828 0.03045876 - 319 25.02427 0.03016069 - 320 25.07025 0.02986805 - 321 25.11624 0.02957839 - 322 25.16223 0.02929353 - 323 25.20822 0.02901141 - 324 25.25421 0.02873359 - 325 25.30020 0.02846205 - 326 25.34618 0.02819317 - 327 25.39217 0.02792873 - 328 25.43816 0.02766804 - 329 25.48415 0.02741122 - 330 25.53014 0.02716141 - 331 25.57613 0.02691392 - 332 25.62211 0.02667042 - 333 25.66810 0.02643176 - 334 25.71409 0.02619636 - 335 25.76008 0.02596855 - 336 25.80607 0.02574274 - 337 25.85205 0.02552043 - 338 25.89804 0.02530404 - 339 25.94403 0.02509069 - 340 25.99002 0.02488434 - 341 26.03601 0.02468024 - 342 26.08200 0.02447907 - 343 26.12798 0.02428492 - 344 26.17397 0.02409369 - 345 26.21996 0.02390830 - 346 26.26595 0.02372566 - 347 26.31194 0.02354538 - 348 26.35793 0.02337318 - 349 26.40391 0.02320361 - 350 26.44990 0.02303878 - 351 26.49589 0.02287714 - 352 26.54188 0.02271737 - 353 26.58787 0.02256654 - 354 26.63386 0.02241795 - 355 26.67984 0.02227310 - 356 26.72583 0.02213183 - 357 26.77182 0.02199280 - 358 26.81781 0.02186177 - 359 26.86380 0.02173334 - 360 26.90978 0.02160773 - 361 26.95577 0.02148603 - 362 27.00176 0.02136695 - 363 27.04775 0.02125487 - 364 27.09374 0.02114561 - 365 27.13973 0.02103838 - 366 27.18571 0.02093532 - 367 27.23170 0.02083524 - 368 27.27769 0.02074112 - 369 27.32368 0.02064992 - 370 27.36967 0.02056030 - 371 27.41566 0.02047474 - 372 27.46164 0.02039260 - 373 27.50763 0.02031517 - 374 27.55362 0.02024078 - 375 27.59961 0.02016787 - 376 27.64560 0.02009856 - 377 27.69159 0.02003304 - 378 27.73757 0.01997098 - 379 27.78356 0.01991208 - 380 27.82955 0.01985465 - 381 27.87554 0.01980028 - 382 27.92153 0.01974991 - 383 27.96751 0.01970192 - 384 28.01350 0.01965712 - 385 28.05949 0.01961378 - 386 28.10548 0.01957296 - 387 28.15147 0.01953613 - 388 28.19746 0.01950107 - 389 28.24344 0.01946859 - 390 28.28943 0.01943782 - 391 28.33542 0.01940902 - 392 28.38141 0.01938404 - 393 28.42740 0.01936032 - 394 28.47339 0.01933858 - 395 28.51937 0.01931873 - 396 28.56536 0.01930031 - 397 28.61135 0.01928536 - 398 28.65734 0.01927128 - 399 28.70333 0.01925863 - 400 28.74932 0.01924791 - 401 28.79530 0.01923824 - 402 28.84129 0.01923131 - 403 28.88728 0.01922504 - 404 28.93327 0.01921975 - 405 28.97926 0.01921625 - 406 29.02524 0.01921356 - 407 29.07123 0.01921260 - 408 29.11722 0.01921225 - 409 29.16321 0.01921249 - 410 29.20920 0.01921420 - 411 29.25519 0.01921642 - 412 29.30117 0.01921958 - 413 29.34716 0.01922318 - 414 29.39315 0.01922707 - 415 29.43914 0.01923191 - 416 29.48513 0.01923695 - 417 29.53112 0.01924231 - 418 29.57710 0.01924787 - 419 29.62309 0.01925352 - 420 29.66908 0.01925935 - 421 29.71507 0.01926511 - 422 29.76106 0.01927077 - 423 29.80705 0.01927629 - 424 29.85303 0.01928165 - 425 29.89902 0.01928649 - 426 29.94501 0.01929092 - 427 29.99100 0.01929501 - 428 30.03699 0.01929852 - 429 30.08297 0.01930154 - 430 30.12896 0.01930349 - 431 30.17495 0.01930462 - 432 30.22094 0.01930530 - 433 30.26693 0.01930494 - 434 30.31292 0.01930365 - 435 30.35890 0.01930090 - 436 30.40489 0.01929689 - 437 30.45088 0.01929230 - 438 30.49687 0.01928644 - 439 30.54286 0.01927896 - 440 30.58885 0.01926983 - 441 30.63483 0.01925902 - 442 30.68082 0.01924751 - 443 30.72681 0.01923460 - 444 30.77280 0.01921923 - 445 30.81879 0.01920221 - 446 30.86477 0.01918310 - 447 30.91076 0.01916315 - 448 30.95675 0.01914168 - 449 31.00274 0.01911698 - 450 31.04873 0.01909073 - 451 31.09472 0.01906222 - 452 31.14070 0.01903252 - 453 31.18669 0.01900126 - 454 31.23268 0.01896605 - 455 31.27867 0.01892941 - 456 31.32466 0.01889058 - 457 31.37065 0.01885004 - 458 31.41663 0.01880804 - 459 31.46262 0.01876140 - 460 31.50861 0.01871351 - 461 31.55460 0.01866360 - 462 31.60059 0.01861140 - 463 31.64658 0.01855789 - 464 31.69256 0.01849926 - 465 31.73855 0.01843954 - 466 31.78454 0.01837801 - 467 31.83053 0.01831361 - 468 31.87652 0.01824765 - 469 31.92250 0.01817718 - 470 31.96849 0.01810530 - 471 32.01448 0.01803190 - 472 32.06047 0.01795502 - 473 32.10646 0.01787646 - 474 32.15245 0.01779407 - 475 32.19843 0.01770999 - 476 32.24442 0.01762469 - 477 32.29041 0.01753534 - 478 32.33640 0.01744433 - 479 32.38239 0.01735019 - 480 32.42838 0.01725411 - 481 32.47436 0.01715692 - 482 32.52035 0.01705562 - 483 32.56634 0.01695257 - 484 32.61233 0.01684709 - 485 32.65832 0.01673947 - 486 32.70431 0.01663062 - 487 32.75029 0.01651816 - 488 32.79628 0.01640373 - 489 32.84227 0.01628752 - 490 32.88826 0.01616907 - 491 32.93425 0.01604927 - 492 32.98023 0.01592641 - 493 33.02622 0.01580152 - 494 33.07221 0.01567540 - 495 33.11820 0.01554700 - 496 33.16419 0.01541719 - 497 33.21018 0.01528492 - 498 33.25616 0.01515064 - 499 33.30215 0.01501542 - 500 33.34814 0.01487837 - 501 33.39413 0.01473969 - 502 33.44012 0.01459914 - 503 33.48611 0.01445674 - 504 33.53209 0.01431362 - 505 33.57808 0.01416910 - 506 33.62407 0.01402287 - 507 33.67006 0.01387533 - 508 33.71605 0.01372619 - 509 33.76204 0.01357651 - 510 33.80802 0.01342584 - 511 33.85401 0.01327351 - 512 33.90000 0.01312032 - ---- - - Code - make_density(c(-Inf, mpg_max)) - Output - x y - 1 10.40000 0.01922607 - 2 10.44599 0.01951572 - 3 10.49198 0.01980789 - 4 10.53796 0.02010489 - 5 10.58395 0.02040455 - 6 10.62994 0.02070565 - 7 10.67593 0.02101099 - 8 10.72192 0.02131954 - 9 10.76791 0.02163230 - 10 10.81389 0.02194827 - 11 10.85988 0.02226590 - 12 10.90587 0.02258777 - 13 10.95186 0.02291365 - 14 10.99785 0.02324302 - 15 11.04384 0.02357619 - 16 11.08982 0.02391129 - 17 11.13581 0.02425046 - 18 11.18180 0.02459440 - 19 11.22779 0.02494107 - 20 11.27378 0.02529202 - 21 11.31977 0.02564523 - 22 11.36575 0.02600221 - 23 11.41174 0.02636458 - 24 11.45773 0.02672930 - 25 11.50372 0.02709788 - 26 11.54971 0.02746948 - 27 11.59569 0.02784438 - 28 11.64168 0.02822509 - 29 11.68767 0.02860778 - 30 11.73366 0.02899380 - 31 11.77965 0.02938356 - 32 11.82564 0.02977602 - 33 11.87162 0.03017445 - 34 11.91761 0.03057448 - 35 11.96360 0.03097727 - 36 12.00959 0.03138436 - 37 12.05558 0.03179373 - 38 12.10157 0.03220837 - 39 12.14755 0.03262454 - 40 12.19354 0.03304285 - 41 12.23953 0.03346580 - 42 12.28552 0.03389072 - 43 12.33151 0.03431953 - 44 12.37750 0.03475001 - 45 12.42348 0.03518202 - 46 12.46947 0.03561862 - 47 12.51546 0.03605671 - 48 12.56145 0.03649743 - 49 12.60744 0.03693974 - 50 12.65342 0.03738301 - 51 12.69941 0.03783036 - 52 12.74540 0.03827861 - 53 12.79139 0.03872837 - 54 12.83738 0.03917945 - 55 12.88337 0.03963126 - 56 12.92935 0.04008553 - 57 12.97534 0.04054034 - 58 13.02133 0.04099578 - 59 13.06732 0.04145199 - 60 13.11331 0.04190854 - 61 13.15930 0.04236587 - 62 13.20528 0.04282319 - 63 13.25127 0.04328051 - 64 13.29726 0.04373778 - 65 13.34325 0.04419473 - 66 13.38924 0.04465092 - 67 13.43523 0.04510635 - 68 13.48121 0.04556137 - 69 13.52720 0.04601535 - 70 13.57319 0.04646798 - 71 13.61918 0.04691861 - 72 13.66517 0.04736759 - 73 13.71115 0.04781574 - 74 13.75714 0.04826189 - 75 13.80313 0.04870530 - 76 13.84912 0.04914604 - 77 13.89511 0.04958398 - 78 13.94110 0.05002061 - 79 13.98708 0.05045443 - 80 14.03307 0.05088381 - 81 14.07906 0.05131036 - 82 14.12505 0.05173279 - 83 14.17104 0.05215333 - 84 14.21703 0.05257047 - 85 14.26301 0.05298129 - 86 14.30900 0.05338916 - 87 14.35499 0.05379229 - 88 14.40098 0.05419243 - 89 14.44697 0.05458886 - 90 14.49295 0.05497703 - 91 14.53894 0.05536224 - 92 14.58493 0.05574259 - 93 14.63092 0.05611843 - 94 14.67691 0.05649059 - 95 14.72290 0.05685261 - 96 14.76888 0.05721183 - 97 14.81487 0.05756631 - 98 14.86086 0.05791455 - 99 14.90685 0.05825922 - 100 14.95284 0.05859255 - 101 14.99883 0.05892308 - 102 15.04481 0.05924925 - 103 15.09080 0.05956725 - 104 15.13679 0.05988117 - 105 15.18278 0.06018477 - 106 15.22877 0.06048466 - 107 15.27476 0.06078073 - 108 15.32074 0.06106667 - 109 15.36673 0.06134831 - 110 15.41272 0.06162095 - 111 15.45871 0.06188900 - 112 15.50470 0.06215393 - 113 15.55068 0.06240678 - 114 15.59667 0.06265545 - 115 15.64266 0.06289662 - 116 15.68865 0.06313239 - 117 15.73464 0.06336498 - 118 15.78063 0.06358537 - 119 15.82661 0.06380121 - 120 15.87260 0.06401108 - 121 15.91859 0.06421486 - 122 15.96458 0.06441490 - 123 16.01057 0.06460393 - 124 16.05656 0.06478777 - 125 16.10254 0.06496713 - 126 16.14853 0.06513985 - 127 16.19452 0.06530830 - 128 16.24051 0.06546715 - 129 16.28650 0.06562045 - 130 16.33249 0.06577056 - 131 16.37847 0.06591375 - 132 16.42446 0.06605214 - 133 16.47045 0.06618249 - 134 16.51644 0.06630715 - 135 16.56243 0.06642913 - 136 16.60841 0.06654530 - 137 16.65440 0.06665560 - 138 16.70039 0.06675946 - 139 16.74638 0.06685771 - 140 16.79237 0.06695366 - 141 16.83836 0.06704488 - 142 16.88434 0.06712934 - 143 16.93033 0.06720892 - 144 16.97632 0.06728313 - 145 17.02231 0.06735527 - 146 17.06830 0.06742355 - 147 17.11429 0.06748461 - 148 17.16027 0.06754207 - 149 17.20626 0.06759485 - 150 17.25225 0.06764537 - 151 17.29824 0.06769273 - 152 17.34423 0.06773286 - 153 17.39022 0.06777034 - 154 17.43620 0.06780404 - 155 17.48219 0.06783504 - 156 17.52818 0.06786356 - 157 17.57417 0.06788496 - 158 17.62016 0.06790443 - 159 17.66614 0.06792089 - 160 17.71213 0.06793424 - 161 17.75812 0.06794574 - 162 17.80411 0.06795025 - 163 17.85010 0.06795336 - 164 17.89609 0.06795409 - 165 17.94207 0.06795131 - 166 17.98806 0.06794663 - 167 18.03405 0.06793625 - 168 18.08004 0.06792426 - 169 18.12603 0.06791038 - 170 18.17202 0.06789255 - 171 18.21800 0.06787277 - 172 18.26399 0.06784837 - 173 18.30998 0.06782205 - 174 18.35597 0.06779427 - 175 18.40196 0.06776197 - 176 18.44795 0.06772771 - 177 18.49393 0.06768963 - 178 18.53992 0.06764932 - 179 18.58591 0.06760770 - 180 18.63190 0.06756120 - 181 18.67789 0.06751255 - 182 18.72387 0.06746073 - 183 18.76986 0.06740627 - 184 18.81585 0.06735025 - 185 18.86184 0.06728952 - 186 18.90783 0.06722610 - 187 18.95382 0.06716007 - 188 18.99980 0.06709088 - 189 19.04579 0.06701978 - 190 19.09178 0.06694410 - 191 19.13777 0.06686513 - 192 19.18376 0.06678406 - 193 19.22975 0.06669922 - 194 19.27573 0.06661197 - 195 19.32172 0.06652030 - 196 19.36771 0.06642467 - 197 19.41370 0.06632713 - 198 19.45969 0.06622578 - 199 19.50568 0.06612103 - 200 19.55166 0.06601210 - 201 19.59765 0.06589852 - 202 19.64364 0.06578308 - 203 19.68963 0.06566400 - 204 19.73562 0.06554024 - 205 19.78160 0.06541265 - 206 19.82759 0.06527974 - 207 19.87358 0.06514499 - 208 19.91957 0.06500682 - 209 19.96556 0.06486247 - 210 20.01155 0.06471472 - 211 20.05753 0.06456125 - 212 20.10352 0.06440580 - 213 20.14951 0.06424724 - 214 20.19550 0.06408081 - 215 20.24149 0.06391113 - 216 20.28748 0.06373639 - 217 20.33346 0.06355900 - 218 20.37945 0.06337890 - 219 20.42544 0.06318912 - 220 20.47143 0.06299648 - 221 20.51742 0.06279950 - 222 20.56341 0.06259901 - 223 20.60939 0.06239615 - 224 20.65538 0.06218237 - 225 20.70137 0.06196630 - 226 20.74736 0.06174642 - 227 20.79335 0.06152209 - 228 20.83933 0.06129511 - 229 20.88532 0.06105778 - 230 20.93131 0.06081799 - 231 20.97730 0.06057499 - 232 21.02329 0.06032655 - 233 21.06928 0.06007497 - 234 21.11526 0.05981461 - 235 21.16125 0.05955125 - 236 21.20724 0.05928530 - 237 21.25323 0.05901300 - 238 21.29922 0.05873735 - 239 21.34521 0.05845451 - 240 21.39119 0.05816824 - 241 21.43718 0.05787999 - 242 21.48317 0.05758470 - 243 21.52916 0.05728606 - 244 21.57515 0.05698180 - 245 21.62114 0.05667382 - 246 21.66712 0.05636377 - 247 21.71311 0.05604756 - 248 21.75910 0.05572758 - 249 21.80509 0.05540346 - 250 21.85108 0.05507548 - 251 21.89706 0.05474540 - 252 21.94305 0.05441016 - 253 21.98904 0.05407102 - 254 22.03503 0.05372907 - 255 22.08102 0.05338331 - 256 22.12701 0.05303547 - 257 22.17299 0.05268356 - 258 22.21898 0.05232794 - 259 22.26497 0.05197043 - 260 22.31096 0.05160972 - 261 22.35695 0.05124688 - 262 22.40294 0.05088107 - 263 22.44892 0.05051203 - 264 22.49491 0.05014169 - 265 22.54090 0.04976912 - 266 22.58689 0.04939444 - 267 22.63288 0.04901784 - 268 22.67886 0.04863873 - 269 22.72485 0.04825883 - 270 22.77084 0.04787753 - 271 22.81683 0.04749450 - 272 22.86282 0.04711043 - 273 22.90881 0.04672481 - 274 22.95479 0.04633880 - 275 23.00078 0.04595210 - 276 23.04677 0.04556441 - 277 23.09276 0.04517632 - 278 23.13875 0.04478786 - 279 23.18474 0.04439928 - 280 23.23072 0.04401057 - 281 23.27671 0.04362202 - 282 23.32270 0.04323363 - 283 23.36869 0.04284573 - 284 23.41468 0.04245815 - 285 23.46067 0.04207082 - 286 23.50665 0.04168518 - 287 23.55264 0.04130012 - 288 23.59863 0.04091610 - 289 23.64462 0.04053298 - 290 23.69061 0.04015044 - 291 23.73659 0.03977124 - 292 23.78258 0.03939293 - 293 23.82857 0.03901593 - 294 23.87456 0.03864058 - 295 23.92055 0.03826641 - 296 23.96654 0.03789658 - 297 24.01252 0.03752816 - 298 24.05851 0.03716111 - 299 24.10450 0.03679671 - 300 24.15049 0.03643417 - 301 24.19648 0.03607632 - 302 24.24247 0.03572053 - 303 24.28845 0.03536606 - 304 24.33444 0.03501541 - 305 24.38043 0.03466729 - 306 24.42642 0.03432379 - 307 24.47241 0.03398307 - 308 24.51840 0.03364385 - 309 24.56438 0.03330903 - 310 24.61037 0.03297766 - 311 24.65636 0.03265054 - 312 24.70235 0.03232695 - 313 24.74834 0.03200518 - 314 24.79432 0.03168798 - 315 24.84031 0.03137526 - 316 24.88630 0.03106617 - 317 24.93229 0.03076136 - 318 24.97828 0.03045876 - 319 25.02427 0.03016069 - 320 25.07025 0.02986805 - 321 25.11624 0.02957839 - 322 25.16223 0.02929353 - 323 25.20822 0.02901141 - 324 25.25421 0.02873359 - 325 25.30020 0.02846205 - 326 25.34618 0.02819317 - 327 25.39217 0.02792873 - 328 25.43816 0.02766804 - 329 25.48415 0.02741122 - 330 25.53014 0.02716141 - 331 25.57613 0.02691392 - 332 25.62211 0.02667042 - 333 25.66810 0.02643176 - 334 25.71409 0.02619636 - 335 25.76008 0.02596855 - 336 25.80607 0.02574274 - 337 25.85205 0.02552043 - 338 25.89804 0.02530404 - 339 25.94403 0.02509069 - 340 25.99002 0.02488434 - 341 26.03601 0.02468024 - 342 26.08200 0.02447907 - 343 26.12798 0.02428492 - 344 26.17397 0.02409369 - 345 26.21996 0.02390830 - 346 26.26595 0.02372566 - 347 26.31194 0.02354538 - 348 26.35793 0.02337318 - 349 26.40391 0.02320361 - 350 26.44990 0.02303878 - 351 26.49589 0.02294418 - 352 26.54188 0.02278834 - 353 26.58787 0.02264170 - 354 26.63386 0.02249740 - 355 26.67984 0.02235701 - 356 26.72583 0.02222059 - 357 26.77182 0.02208662 - 358 26.81781 0.02196095 - 359 26.86380 0.02183801 - 360 26.90978 0.02171810 - 361 26.95577 0.02160264 - 362 27.00176 0.02149000 - 363 27.04775 0.02138469 - 364 27.09374 0.02128242 - 365 27.13973 0.02118239 - 366 27.18571 0.02108725 - 367 27.23170 0.02099531 - 368 27.27769 0.02090967 - 369 27.32368 0.02082729 - 370 27.36967 0.02074671 - 371 27.41566 0.02067112 - 372 27.46164 0.02059915 - 373 27.50763 0.02053226 - 374 27.55362 0.02046891 - 375 27.59961 0.02040733 - 376 27.64560 0.02035035 - 377 27.69159 0.02029745 - 378 27.73757 0.02024837 - 379 27.78356 0.02020317 - 380 27.82955 0.02015982 - 381 27.87554 0.02012056 - 382 27.92153 0.02008570 - 383 27.96751 0.02005356 - 384 28.01350 0.02002562 - 385 28.05949 0.01999962 - 386 28.10548 0.01997713 - 387 28.15147 0.01995921 - 388 28.19746 0.01994338 - 389 28.24344 0.01993143 - 390 28.28943 0.01992179 - 391 28.33542 0.01991506 - 392 28.38141 0.01991291 - 393 28.42740 0.01991246 - 394 28.47339 0.01991540 - 395 28.51937 0.01992104 - 396 28.56536 0.01992897 - 397 28.61135 0.01994135 - 398 28.65734 0.01995519 - 399 28.70333 0.01997193 - 400 28.74932 0.01999167 - 401 28.79530 0.02001320 - 402 28.84129 0.02003870 - 403 28.88728 0.02006565 - 404 28.93327 0.02009506 - 405 28.97926 0.02012761 - 406 29.02524 0.02016165 - 407 29.07123 0.02019876 - 408 29.11722 0.02023758 - 409 29.16321 0.02027844 - 410 29.20920 0.02032242 - 411 29.25519 0.02036757 - 412 29.30117 0.02041495 - 413 29.34716 0.02046435 - 414 29.39315 0.02051541 - 415 29.43914 0.02056932 - 416 29.48513 0.02062409 - 417 29.53112 0.02068042 - 418 29.57710 0.02073907 - 419 29.62309 0.02079902 - 420 29.66908 0.02086128 - 421 29.71507 0.02092416 - 422 29.76106 0.02098809 - 423 29.80705 0.02105459 - 424 29.85303 0.02112213 - 425 29.89902 0.02119108 - 426 29.94501 0.02126054 - 427 29.99100 0.02133068 - 428 30.03699 0.02140364 - 429 30.08297 0.02147720 - 430 30.12896 0.02155137 - 431 30.17495 0.02162593 - 432 30.22094 0.02170092 - 433 30.26693 0.02177891 - 434 30.31292 0.02185685 - 435 30.35890 0.02193479 - 436 30.40489 0.02201306 - 437 30.45088 0.02209169 - 438 30.49687 0.02217308 - 439 30.54286 0.02225376 - 440 30.58885 0.02233405 - 441 30.63483 0.02241462 - 442 30.68082 0.02249569 - 443 30.72681 0.02257887 - 444 30.77280 0.02266074 - 445 30.81879 0.02274200 - 446 30.86477 0.02282355 - 447 30.91076 0.02290559 - 448 30.95675 0.02298909 - 449 31.00274 0.02307071 - 450 31.04873 0.02315159 - 451 31.09472 0.02323301 - 452 31.14070 0.02331460 - 453 31.18669 0.02339707 - 454 31.23268 0.02347711 - 455 31.27867 0.02355658 - 456 31.32466 0.02363646 - 457 31.37065 0.02371624 - 458 31.41663 0.02379644 - 459 31.46262 0.02387367 - 460 31.50861 0.02395057 - 461 31.55460 0.02402774 - 462 31.60059 0.02410441 - 463 31.64658 0.02418113 - 464 31.69256 0.02425449 - 465 31.73855 0.02432772 - 466 31.78454 0.02440110 - 467 31.83053 0.02447344 - 468 31.87652 0.02454519 - 469 31.92250 0.02461409 - 470 31.96849 0.02468264 - 471 32.01448 0.02475122 - 472 32.06047 0.02481811 - 473 32.10646 0.02488406 - 474 32.15245 0.02494748 - 475 32.19843 0.02501039 - 476 32.24442 0.02507325 - 477 32.29041 0.02513368 - 478 32.33640 0.02519299 - 479 32.38239 0.02525012 - 480 32.42838 0.02530653 - 481 32.47436 0.02536260 - 482 32.52035 0.02541593 - 483 32.56634 0.02546787 - 484 32.61233 0.02551802 - 485 32.65832 0.02556714 - 486 32.70431 0.02561553 - 487 32.75029 0.02566116 - 488 32.79628 0.02570513 - 489 32.84227 0.02574768 - 490 32.88826 0.02578879 - 491 32.93425 0.02582884 - 492 32.98023 0.02586619 - 493 33.02622 0.02590170 - 494 33.07221 0.02593614 - 495 33.11820 0.02596863 - 496 33.16419 0.02599975 - 497 33.21018 0.02602842 - 498 33.25616 0.02605508 - 499 33.30215 0.02608080 - 500 33.34814 0.02610434 - 501 33.39413 0.02612612 - 502 33.44012 0.02614579 - 503 33.48611 0.02616334 - 504 33.53209 0.02617995 - 505 33.57808 0.02619419 - 506 33.62407 0.02620636 - 507 33.67006 0.02621684 - 508 33.71605 0.02622507 - 509 33.76204 0.02623224 - 510 33.80802 0.02623701 - 511 33.85401 0.02623948 - 512 33.90000 0.02624065 - ---- - - Code - make_density(c(mpg_min, mpg_max)) - Output - x y - 1 10.40000 0.03845214 - 2 10.44599 0.03845598 - 3 10.49198 0.03846380 - 4 10.53796 0.03847855 - 5 10.58395 0.03850133 - 6 10.62994 0.03852762 - 7 10.67593 0.03856114 - 8 10.72192 0.03859957 - 9 10.76791 0.03864387 - 10 10.81389 0.03869712 - 11 10.85988 0.03875358 - 12 10.90587 0.03881660 - 13 10.95186 0.03888567 - 14 10.99785 0.03895953 - 15 11.04384 0.03904294 - 16 11.08982 0.03912938 - 17 11.13581 0.03922177 - 18 11.18180 0.03932129 - 19 11.22779 0.03942492 - 20 11.27378 0.03953769 - 21 11.31977 0.03965393 - 22 11.36575 0.03977543 - 23 11.41174 0.03990500 - 24 11.45773 0.04003842 - 25 11.50372 0.04017964 - 26 11.54971 0.04032529 - 27 11.59569 0.04047540 - 28 11.64168 0.04063437 - 29 11.68767 0.04079685 - 30 11.73366 0.04096586 - 31 11.77965 0.04114024 - 32 11.82564 0.04131825 - 33 11.87162 0.04150552 - 34 11.91761 0.04169604 - 35 11.96360 0.04189187 - 36 12.00959 0.04209387 - 37 12.05558 0.04229917 - 38 12.10157 0.04251278 - 39 12.14755 0.04272990 - 40 12.19354 0.04295119 - 41 12.23953 0.04317921 - 42 12.28552 0.04341038 - 43 12.33151 0.04364825 - 44 12.37750 0.04389009 - 45 12.42348 0.04413500 - 46 12.46947 0.04438689 - 47 12.51546 0.04464163 - 48 12.56145 0.04490157 - 49 12.60744 0.04516572 - 50 12.65342 0.04543212 - 51 12.69941 0.04570492 - 52 12.74540 0.04598040 - 53 12.79139 0.04625971 - 54 12.83738 0.04654325 - 55 12.88337 0.04682867 - 56 12.92935 0.04711866 - 57 12.97534 0.04741152 - 58 13.02133 0.04770703 - 59 13.06732 0.04800650 - 60 13.11331 0.04830735 - 61 13.15930 0.04861086 - 62 13.20528 0.04891730 - 63 13.25127 0.04922543 - 64 13.29726 0.04953688 - 65 13.34325 0.04984900 - 66 13.38924 0.05016200 - 67 13.43523 0.05047785 - 68 13.48121 0.05079488 - 69 13.52720 0.05111376 - 70 13.57319 0.05143256 - 71 13.61918 0.05175075 - 72 13.66517 0.05207155 - 73 13.71115 0.05239297 - 74 13.75714 0.05271480 - 75 13.80313 0.05303543 - 76 13.84912 0.05335451 - 77 13.89511 0.05367573 - 78 13.94110 0.05399682 - 79 13.98708 0.05431705 - 80 14.03307 0.05463465 - 81 14.07906 0.05495052 - 82 14.12505 0.05526732 - 83 14.17104 0.05558333 - 84 14.21703 0.05589747 - 85 14.26301 0.05620742 - 86 14.30900 0.05651578 - 87 14.35499 0.05682375 - 88 14.40098 0.05713003 - 89 14.44697 0.05743379 - 90 14.49295 0.05773177 - 91 14.53894 0.05802833 - 92 14.58493 0.05832358 - 93 14.63092 0.05861582 - 94 14.67691 0.05890528 - 95 14.72290 0.05918741 - 96 14.76888 0.05946834 - 97 14.81487 0.05974734 - 98 14.86086 0.06002176 - 99 14.90685 0.06029351 - 100 14.95284 0.06055645 - 101 14.99883 0.06081847 - 102 15.04481 0.06107825 - 103 15.09080 0.06133165 - 104 15.13679 0.06158188 - 105 15.18278 0.06182400 - 106 15.22877 0.06206446 - 107 15.27476 0.06230264 - 108 15.32074 0.06253254 - 109 15.36673 0.06275909 - 110 15.41272 0.06297852 - 111 15.45871 0.06319548 - 112 15.50470 0.06341042 - 113 15.55068 0.06361503 - 114 15.59667 0.06381652 - 115 15.64266 0.06401204 - 116 15.68865 0.06420429 - 117 15.73464 0.06439420 - 118 15.78063 0.06457334 - 119 15.82661 0.06474917 - 120 15.87260 0.06492023 - 121 15.91859 0.06508726 - 122 15.96458 0.06525120 - 123 16.01057 0.06540525 - 124 16.05656 0.06555551 - 125 16.10254 0.06570217 - 126 16.14853 0.06584414 - 127 16.19452 0.06598234 - 128 16.24051 0.06611180 - 129 16.28650 0.06623720 - 130 16.33249 0.06636015 - 131 16.37847 0.06647770 - 132 16.42446 0.06659097 - 133 16.47045 0.06669684 - 134 16.51644 0.06679857 - 135 16.56243 0.06689820 - 136 16.60841 0.06699316 - 137 16.65440 0.06708280 - 138 16.70039 0.06716644 - 139 16.74638 0.06724604 - 140 16.79237 0.06732379 - 141 16.83836 0.06739761 - 142 16.88434 0.06746523 - 143 16.93033 0.06752830 - 144 16.97632 0.06758747 - 145 17.02231 0.06764491 - 146 17.06830 0.06769904 - 147 17.11429 0.06774651 - 148 17.16027 0.06779072 - 149 17.20626 0.06783139 - 150 17.25225 0.06787014 - 151 17.29824 0.06790610 - 152 17.34423 0.06793535 - 153 17.39022 0.06796230 - 154 17.43620 0.06798634 - 155 17.48219 0.06800801 - 156 17.52818 0.06802742 - 157 17.57417 0.06804021 - 158 17.62016 0.06805140 - 159 17.66614 0.06806022 - 160 17.71213 0.06806624 - 161 17.75812 0.06807055 - 162 17.80411 0.06806829 - 163 17.85010 0.06795336 - 164 17.89609 0.06795409 - 165 17.94207 0.06795131 - 166 17.98806 0.06794663 - 167 18.03405 0.06793625 - 168 18.08004 0.06792426 - 169 18.12603 0.06791038 - 170 18.17202 0.06789255 - 171 18.21800 0.06787277 - 172 18.26399 0.06784837 - 173 18.30998 0.06782205 - 174 18.35597 0.06779427 - 175 18.40196 0.06776197 - 176 18.44795 0.06772771 - 177 18.49393 0.06768963 - 178 18.53992 0.06764932 - 179 18.58591 0.06760770 - 180 18.63190 0.06756120 - 181 18.67789 0.06751255 - 182 18.72387 0.06746073 - 183 18.76986 0.06740627 - 184 18.81585 0.06735025 - 185 18.86184 0.06728952 - 186 18.90783 0.06722610 - 187 18.95382 0.06716007 - 188 18.99980 0.06709088 - 189 19.04579 0.06701978 - 190 19.09178 0.06694410 - 191 19.13777 0.06686513 - 192 19.18376 0.06678406 - 193 19.22975 0.06669922 - 194 19.27573 0.06661197 - 195 19.32172 0.06652030 - 196 19.36771 0.06642467 - 197 19.41370 0.06632713 - 198 19.45969 0.06622578 - 199 19.50568 0.06612103 - 200 19.55166 0.06601210 - 201 19.59765 0.06589852 - 202 19.64364 0.06578308 - 203 19.68963 0.06566400 - 204 19.73562 0.06554024 - 205 19.78160 0.06541265 - 206 19.82759 0.06527974 - 207 19.87358 0.06514499 - 208 19.91957 0.06500682 - 209 19.96556 0.06486247 - 210 20.01155 0.06471472 - 211 20.05753 0.06456125 - 212 20.10352 0.06440580 - 213 20.14951 0.06424724 - 214 20.19550 0.06408081 - 215 20.24149 0.06391113 - 216 20.28748 0.06373639 - 217 20.33346 0.06355900 - 218 20.37945 0.06337890 - 219 20.42544 0.06318912 - 220 20.47143 0.06299648 - 221 20.51742 0.06279950 - 222 20.56341 0.06259901 - 223 20.60939 0.06239615 - 224 20.65538 0.06218237 - 225 20.70137 0.06196630 - 226 20.74736 0.06174642 - 227 20.79335 0.06152209 - 228 20.83933 0.06129511 - 229 20.88532 0.06105778 - 230 20.93131 0.06081799 - 231 20.97730 0.06057499 - 232 21.02329 0.06032655 - 233 21.06928 0.06007497 - 234 21.11526 0.05981461 - 235 21.16125 0.05955125 - 236 21.20724 0.05928530 - 237 21.25323 0.05901300 - 238 21.29922 0.05873735 - 239 21.34521 0.05845451 - 240 21.39119 0.05816824 - 241 21.43718 0.05787999 - 242 21.48317 0.05758470 - 243 21.52916 0.05728606 - 244 21.57515 0.05698180 - 245 21.62114 0.05667382 - 246 21.66712 0.05636377 - 247 21.71311 0.05604756 - 248 21.75910 0.05572758 - 249 21.80509 0.05540346 - 250 21.85108 0.05507548 - 251 21.89706 0.05474540 - 252 21.94305 0.05441016 - 253 21.98904 0.05407102 - 254 22.03503 0.05372907 - 255 22.08102 0.05338331 - 256 22.12701 0.05303547 - 257 22.17299 0.05268356 - 258 22.21898 0.05232794 - 259 22.26497 0.05197043 - 260 22.31096 0.05160972 - 261 22.35695 0.05124688 - 262 22.40294 0.05088107 - 263 22.44892 0.05051203 - 264 22.49491 0.05014169 - 265 22.54090 0.04976912 - 266 22.58689 0.04939444 - 267 22.63288 0.04901784 - 268 22.67886 0.04863873 - 269 22.72485 0.04825883 - 270 22.77084 0.04787753 - 271 22.81683 0.04749450 - 272 22.86282 0.04711043 - 273 22.90881 0.04672481 - 274 22.95479 0.04633880 - 275 23.00078 0.04595210 - 276 23.04677 0.04556441 - 277 23.09276 0.04517632 - 278 23.13875 0.04478786 - 279 23.18474 0.04439928 - 280 23.23072 0.04401057 - 281 23.27671 0.04362202 - 282 23.32270 0.04323363 - 283 23.36869 0.04284573 - 284 23.41468 0.04245815 - 285 23.46067 0.04207082 - 286 23.50665 0.04168518 - 287 23.55264 0.04130012 - 288 23.59863 0.04091610 - 289 23.64462 0.04053298 - 290 23.69061 0.04015044 - 291 23.73659 0.03977124 - 292 23.78258 0.03939293 - 293 23.82857 0.03901593 - 294 23.87456 0.03864058 - 295 23.92055 0.03826641 - 296 23.96654 0.03789658 - 297 24.01252 0.03752816 - 298 24.05851 0.03716111 - 299 24.10450 0.03679671 - 300 24.15049 0.03643417 - 301 24.19648 0.03607632 - 302 24.24247 0.03572053 - 303 24.28845 0.03536606 - 304 24.33444 0.03501541 - 305 24.38043 0.03466729 - 306 24.42642 0.03432379 - 307 24.47241 0.03398307 - 308 24.51840 0.03364385 - 309 24.56438 0.03330903 - 310 24.61037 0.03297766 - 311 24.65636 0.03265054 - 312 24.70235 0.03232695 - 313 24.74834 0.03200518 - 314 24.79432 0.03168798 - 315 24.84031 0.03137526 - 316 24.88630 0.03106617 - 317 24.93229 0.03076136 - 318 24.97828 0.03045876 - 319 25.02427 0.03016069 - 320 25.07025 0.02986805 - 321 25.11624 0.02957839 - 322 25.16223 0.02929353 - 323 25.20822 0.02901141 - 324 25.25421 0.02873359 - 325 25.30020 0.02846205 - 326 25.34618 0.02819317 - 327 25.39217 0.02792873 - 328 25.43816 0.02766804 - 329 25.48415 0.02741122 - 330 25.53014 0.02716141 - 331 25.57613 0.02691392 - 332 25.62211 0.02667042 - 333 25.66810 0.02643176 - 334 25.71409 0.02619636 - 335 25.76008 0.02596855 - 336 25.80607 0.02574274 - 337 25.85205 0.02552043 - 338 25.89804 0.02530404 - 339 25.94403 0.02509069 - 340 25.99002 0.02488434 - 341 26.03601 0.02468024 - 342 26.08200 0.02447907 - 343 26.12798 0.02428492 - 344 26.17397 0.02409369 - 345 26.21996 0.02390830 - 346 26.26595 0.02372566 - 347 26.31194 0.02354538 - 348 26.35793 0.02337318 - 349 26.40391 0.02320361 - 350 26.44990 0.02303878 - 351 26.49589 0.02294418 - 352 26.54188 0.02278834 - 353 26.58787 0.02264170 - 354 26.63386 0.02249740 - 355 26.67984 0.02235701 - 356 26.72583 0.02222059 - 357 26.77182 0.02208662 - 358 26.81781 0.02196095 - 359 26.86380 0.02183801 - 360 26.90978 0.02171810 - 361 26.95577 0.02160264 - 362 27.00176 0.02149000 - 363 27.04775 0.02138469 - 364 27.09374 0.02128242 - 365 27.13973 0.02118239 - 366 27.18571 0.02108725 - 367 27.23170 0.02099531 - 368 27.27769 0.02090967 - 369 27.32368 0.02082729 - 370 27.36967 0.02074671 - 371 27.41566 0.02067112 - 372 27.46164 0.02059915 - 373 27.50763 0.02053226 - 374 27.55362 0.02046891 - 375 27.59961 0.02040733 - 376 27.64560 0.02035035 - 377 27.69159 0.02029745 - 378 27.73757 0.02024837 - 379 27.78356 0.02020317 - 380 27.82955 0.02015982 - 381 27.87554 0.02012056 - 382 27.92153 0.02008570 - 383 27.96751 0.02005356 - 384 28.01350 0.02002562 - 385 28.05949 0.01999962 - 386 28.10548 0.01997713 - 387 28.15147 0.01995921 - 388 28.19746 0.01994338 - 389 28.24344 0.01993143 - 390 28.28943 0.01992179 - 391 28.33542 0.01991506 - 392 28.38141 0.01991291 - 393 28.42740 0.01991246 - 394 28.47339 0.01991540 - 395 28.51937 0.01992104 - 396 28.56536 0.01992897 - 397 28.61135 0.01994135 - 398 28.65734 0.01995519 - 399 28.70333 0.01997193 - 400 28.74932 0.01999167 - 401 28.79530 0.02001320 - 402 28.84129 0.02003870 - 403 28.88728 0.02006565 - 404 28.93327 0.02009506 - 405 28.97926 0.02012761 - 406 29.02524 0.02016165 - 407 29.07123 0.02019876 - 408 29.11722 0.02023758 - 409 29.16321 0.02027844 - 410 29.20920 0.02032242 - 411 29.25519 0.02036757 - 412 29.30117 0.02041495 - 413 29.34716 0.02046435 - 414 29.39315 0.02051541 - 415 29.43914 0.02056932 - 416 29.48513 0.02062409 - 417 29.53112 0.02068042 - 418 29.57710 0.02073907 - 419 29.62309 0.02079902 - 420 29.66908 0.02086128 - 421 29.71507 0.02092416 - 422 29.76106 0.02098809 - 423 29.80705 0.02105459 - 424 29.85303 0.02112213 - 425 29.89902 0.02119108 - 426 29.94501 0.02126054 - 427 29.99100 0.02133068 - 428 30.03699 0.02140364 - 429 30.08297 0.02147720 - 430 30.12896 0.02155137 - 431 30.17495 0.02162593 - 432 30.22094 0.02170092 - 433 30.26693 0.02177891 - 434 30.31292 0.02185685 - 435 30.35890 0.02193479 - 436 30.40489 0.02201306 - 437 30.45088 0.02209169 - 438 30.49687 0.02217308 - 439 30.54286 0.02225376 - 440 30.58885 0.02233405 - 441 30.63483 0.02241462 - 442 30.68082 0.02249569 - 443 30.72681 0.02257887 - 444 30.77280 0.02266074 - 445 30.81879 0.02274200 - 446 30.86477 0.02282355 - 447 30.91076 0.02290559 - 448 30.95675 0.02298909 - 449 31.00274 0.02307071 - 450 31.04873 0.02315159 - 451 31.09472 0.02323301 - 452 31.14070 0.02331460 - 453 31.18669 0.02339707 - 454 31.23268 0.02347711 - 455 31.27867 0.02355658 - 456 31.32466 0.02363646 - 457 31.37065 0.02371624 - 458 31.41663 0.02379644 - 459 31.46262 0.02387367 - 460 31.50861 0.02395057 - 461 31.55460 0.02402774 - 462 31.60059 0.02410441 - 463 31.64658 0.02418113 - 464 31.69256 0.02425449 - 465 31.73855 0.02432772 - 466 31.78454 0.02440110 - 467 31.83053 0.02447344 - 468 31.87652 0.02454519 - 469 31.92250 0.02461409 - 470 31.96849 0.02468264 - 471 32.01448 0.02475122 - 472 32.06047 0.02481811 - 473 32.10646 0.02488406 - 474 32.15245 0.02494748 - 475 32.19843 0.02501039 - 476 32.24442 0.02507325 - 477 32.29041 0.02513368 - 478 32.33640 0.02519299 - 479 32.38239 0.02525012 - 480 32.42838 0.02530653 - 481 32.47436 0.02536260 - 482 32.52035 0.02541593 - 483 32.56634 0.02546787 - 484 32.61233 0.02551802 - 485 32.65832 0.02556714 - 486 32.70431 0.02561553 - 487 32.75029 0.02566116 - 488 32.79628 0.02570513 - 489 32.84227 0.02574768 - 490 32.88826 0.02578879 - 491 32.93425 0.02582884 - 492 32.98023 0.02586619 - 493 33.02622 0.02590170 - 494 33.07221 0.02593614 - 495 33.11820 0.02596863 - 496 33.16419 0.02599975 - 497 33.21018 0.02602842 - 498 33.25616 0.02605508 - 499 33.30215 0.02608080 - 500 33.34814 0.02610434 - 501 33.39413 0.02612612 - 502 33.44012 0.02614579 - 503 33.48611 0.02616334 - 504 33.53209 0.02617995 - 505 33.57808 0.02619419 - 506 33.62407 0.02620636 - 507 33.67006 0.02621684 - 508 33.71605 0.02622507 - 509 33.76204 0.02623224 - 510 33.80802 0.02623701 - 511 33.85401 0.02623948 - 512 33.90000 0.02624065 - # stat_density works in both directions Problem while computing stat. diff --git a/tests/testthat/test-stat-density.R b/tests/testthat/test-stat-density.R index 2e2af6d0c8..ca494e0788 100644 --- a/tests/testthat/test-stat-density.R +++ b/tests/testthat/test-stat-density.R @@ -15,35 +15,75 @@ test_that("stat_density actually computes density", { ) }) -test_that("stat_density uses `bounds`", { - make_density <- function(bounds) { - plot <- ggplot(mtcars, aes(mpg)) + stat_density(bounds = bounds) - return(layer_data(plot)[, c("x", "y")]) - } +test_that("stat_density can make weighted density estimation", { + df <- mtcars + df$weight <- mtcars$cyl / sum(mtcars$cyl) + + dens <- stats::density(df$mpg, weights = df$weight) + expected_density_fun <- stats::approxfun(data.frame(x = dens$x, y = dens$y)) + + plot <- ggplot(df, aes(mpg, weight = weight)) + stat_density() + actual_density_fun <- stats::approxfun(layer_data(plot)[, c("x", "y")]) + + test_sample <- unique(df$mpg) + expect_equal( + expected_density_fun(test_sample), + actual_density_fun(test_sample), + tolerance = 1e-3 + ) +}) +test_that("stat_density uses `bounds`", { mpg_min <- min(mtcars$mpg) mpg_max <- max(mtcars$mpg) - # Density should be around twice higher at finite boundary - expect_snapshot(make_density(c(-Inf, Inf))) - expect_snapshot(make_density(c(mpg_min, Inf))) - expect_snapshot(make_density(c(-Inf, mpg_max))) - expect_snapshot(make_density(c(mpg_min, mpg_max))) + expect_bounds <- function(bounds) { + dens <- stats::density(mtcars$mpg) + orig_density <- stats::approxfun( + data.frame(x = dens$x, y = dens$y), + yleft = 0, + yright = 0 + ) + + bounded_plot <- ggplot(mtcars, aes(mpg)) + stat_density(bounds = bounds) + bounded_data <- layer_data(bounded_plot)[, c("x", "y")] + plot_density <- stats::approxfun(bounded_data, yleft = 0, yright = 0) + + test_sample <- seq(mpg_min, mpg_max, by = 0.1) + left_reflection <- orig_density(bounds[1] + (bounds[1] - test_sample)) + right_reflection <- orig_density(bounds[2] + (bounds[2] - test_sample)) + + # Plot density should be an original plus added reflection at both `bounds` + # (reflection around infinity is zero) + expect_equal( + orig_density(test_sample) + left_reflection + right_reflection, + plot_density(test_sample), + tolerance = 1e-4 + ) + } + + expect_bounds(c(-Inf, Inf)) + expect_bounds(c(mpg_min, Inf)) + expect_bounds(c(-Inf, mpg_max)) + expect_bounds(c(mpg_min, mpg_max)) }) test_that("stat_density handles data outside of `bounds`", { cutoff <- mtcars$mpg[1] + # Both `x` and `weight` should be filtered out for out of `bounds` points expect_warning( data_actual <- layer_data( - ggplot(mtcars, aes(mpg)) + stat_density(bounds = c(cutoff, Inf)) + ggplot(mtcars, aes(mpg, weight = cyl)) + + stat_density(bounds = c(cutoff, Inf)) ), "outside of `bounds`" ) mtcars_filtered <- mtcars[mtcars$mpg >= cutoff, ] data_expected <- layer_data( - ggplot(mtcars_filtered, aes(mpg)) + stat_density(bounds = c(cutoff, Inf)) + ggplot(mtcars_filtered, aes(mpg, weight = cyl)) + + stat_density(bounds = c(cutoff, Inf)) ) expect_equal(data_actual, data_expected) From 5173f976b06ef83e881f9080e091c6e7c8aee159 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 12 Jul 2022 21:29:36 +0300 Subject: [PATCH 8/8] Update 'NEWS.md'. --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index df68e55fd5..793a9dd82f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # ggplot2 (development version) +* `geom_density()` and `stat_density()` now support `bounds` argument + to estimate density with boundary correction (@echasnovski, #4013). + * ggplot now checks during statistical transformations whether any data columns were dropped and warns about this. If stats intend to drop data columns they can declare them in the new field `dropped_aes`.