Description Usage Arguments Details Value See Also Examples
View source: R/percentile_cut.R
This function is a small wrapper around percentify
. This
function takes a vector of points and creates ranges between those points,
resulting in non-overlapping groups.
1 | percentify_cut(data, var, q = numeric())
|
data |
A data.frame or tibble, |
var |
Variable to do grouping by as string or symbol. |
q |
Numerical values for cutting points. Must be between 0 and 1. |
There is a ggplot2::autoplot()
to visualize the the percentile ranges.
percentile grouped tibble
cut_evenly
Other percentile samplers: autoplot.percentiled_df
,
percentify_max
,
percentify_min
,
percentify_random
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | library(dplyr)
library(broom)
percent_mtcars <- percentify_cut(mtcars, mpg, c(0.25, 0.5, 0.75))
percent_mtcars
summarize(percent_mtcars,
mean_hp = mean(hp),
mean_wt = mean(wt),
n_obs = n()
)
percent_mtcars %>%
group_modify(~tidy(lm(disp ~ wt + cyl, data = .x)))
# cut_evenly() can be used to create cuts
percentify_cut(mtcars, mpg, cut_evenly(8))
library(ggplot2)
autoplot(percent_mtcars)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.