Description Usage Arguments Value See Also Examples
Bin data along a continuous variable
1 2 |
x |
Dataset-like object to bin. Built-in methods for data frames, grouped data frames and ggvis visualisations. |
x_var,w_var |
Names of x and weight variables. The x variable must be continuous. |
width |
The width of the bins. The default is |
center |
The center of one of the bins. Note that if center is above or below
the range of the data, things will be shifted by an appropriate number of |
boundary |
A boundary between two bins. As with |
closed |
One of |
pad |
If |
A data frame with columns:
count_ |
the number of points |
x_ |
mid-point of bin |
xmin_ |
left boundary of bin |
xmax_ |
right boundary of bin |
width_ |
width of bin |
compute_count
For counting cases at specific locations
of a continuous variable. This is useful when the variable is continuous
but the data is granular.
1 2 3 4 5 6 7 | mtcars %>% compute_bin(~mpg)
mtcars %>% compute_bin(~mpg, width = 10)
mtcars %>% group_by(cyl) %>% compute_bin(~mpg, width = 10)
# It doesn't matter whether you transform inside or outside of a vis
mtcars %>% compute_bin(~mpg) %>% ggvis(~x_, ~count_) %>% layer_paths()
mtcars %>% ggvis(~ x_, ~ count_) %>% compute_bin(~mpg) %>% layer_paths()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.