View source: R/tidy_quantiles.R
tidy_quantiles | R Documentation |
Fast grouped sample quantiles
tidy_quantiles(
data,
...,
probs = seq(0, 1, 0.25),
type = 7,
pivot = c("long", "wide"),
na.rm = TRUE,
.by = NULL,
.cols = NULL,
.order = group_by_order_default(data),
.drop_groups = deprecated()
)
data |
A data frame. |
... |
|
probs |
|
type |
|
pivot |
|
na.rm |
|
.by |
(Optional). A selection of columns to group by for this operation. Columns are specified using tidy-select. |
.cols |
(Optional) alternative to |
.order |
Should the groups be returned in sorted order?
If |
.drop_groups |
|
A data frame of sample quantiles.
library(fastplyr)
library(dplyr)
groups <- 1 * 2^(0:10)
# Normal distributed samples by group using the group value as the mean
# and sqrt(groups) as the sd
samples <- tibble(groups) |>
reframe(x = rnorm(100, mean = groups, sd = sqrt(groups)), .by = groups) |>
f_group_by(groups)
# Fast means and quantiles by group
quantiles <- samples |>
tidy_quantiles(x, pivot = "wide")
means <- samples |>
f_summarise(mean = mean(x))
means |>
f_left_join(quantiles)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.