calc_quantiles: Sample Quantiles

View source: R/calc_quantiles.R

calc_quantilesR Documentation

Sample Quantiles

Description

This is a wrapper function for quantile for easy use with data frames.

Usage

calc_quantiles(
  .data,
  value = NA,
  probs = c(q0 = 0, q25 = 0.25, q50 = 0.5, q75 = 0.75, q100 = 1),
  na.rm = TRUE,
  type = 7
)

calc_quantiles_(
  .data,
  value = "value",
  probs = c(q0 = 0, q25 = 0.25, q50 = 0.5, q75 = 0.75, q100 = 1),
  na.rm = TRUE,
  type = 7
)

Arguments

.data

a data frame, possibly grouped

value

column name for which sample quantiles should be calculated

probs

named numeric vector of probabilities with values in [0, 1].

na.rm

logical; if TRUE, any NA and NaNs are removed from data before the quantiles are computed.

type

an integer between 1 and 9 select one of the nine quantile algorithms detailed in quantile to be used.

Value

A data frame.

Author(s)

Michaja Pehl

Examples

require(dplyr)
require(tidyr)

tibble(group = rep(c("A", "B"), 10),
               value = 1:20) %>%
    group_by(group) %>%
    calc_quantiles() %>%
    pivot_wider(names_from = 'quantile')


pik-piam/quitte documentation built on April 26, 2024, 12:58 a.m.