compute_density {ggvis} | R Documentation |
Compute density of data.
Description
Compute density of data.
Usage
compute_density(
x,
x_var,
w_var = NULL,
kernel = "gaussian",
trim = FALSE,
n = 256L,
na.rm = FALSE,
...
)
Arguments
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 |
Value
A data frame with columns:
pred_ |
regularly spaced grid of |
resp_ |
density estimate |
Examples
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_)
[Package ggvis version 0.4.9 Index]