View source: R/compute_density.R
compute_density | R Documentation |
Compute density of data.
compute_density(
x,
x_var,
w_var = NULL,
kernel = "gaussian",
trim = FALSE,
n = 256L,
na.rm = FALSE,
...
)
x |
Dataset (data frame, |
x_var , w_var |
Names of variables to use for x position, and for weights. |
kernel |
Smoothing kernel. See |
trim |
If |
n |
Number of points (along x) to use in the density estimate. |
na.rm |
If |
... |
Additional arguments passed on to |
A data frame with columns:
pred_ |
regularly spaced grid of |
resp_ |
density estimate |
mtcars %>% compute_density(~mpg, n = 5)
mtcars %>% group_by(cyl) %>% compute_density(~mpg, n = 5)
mtcars %>% ggvis(~mpg) %>% compute_density(~mpg, n = 5) %>%
layer_points(~pred_, ~resp_)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.