summarize_quants: Calculate arbitrary quantiles for particular column(s) by...

View source: R/quantiles.R

summarize_quantsR Documentation

Calculate arbitrary quantiles for particular column(s) by group

Description

Calculate arbitrary quantiles for particular column(s) by group and create a summary data.frame which holds a column for each unique combination of values of columns (cols) and quantile values (probs).

Usage

summarize_quants(
  df = NULL,
  grp_cols = NULL,
  cols = NULL,
  probs = c(0.05, 0.25, 0.5, 0.75, 0.95),
  include_mean = TRUE,
  check_args = TRUE
)

Arguments

df

A data.frame

grp_cols

A character vector of the column names to use for grouping the data

cols

A character vector representing column names on which to perform the calculations

probs

A vector of quantile probabilities to pass to stats::quantile

include_mean

If TRUE, include the mean in the output as the column ending in ⁠*_avg⁠

check_args

If TRUE, run the code that verifies the argument constraints. If FALSE skip the tests. You may want to choose FALSE for situations when this function is placed in a loop to be run many times for speed savings reasons

Details

Create a new data.frame which summarizes the one passed as df. The summary data.frame will have a column for each grouping column (grp_cols) and a set of columns for each column name (cols), where the set of columns is one for each value of probs. New columns will be compose of the name in cols, an underscore, and the value in probs.

Value

A data.frame with a new column for each value in the probs vector and a column for the mean in include_mean is TRUE


pbs-assess/gfutilities documentation built on Sept. 18, 2023, 7:57 a.m.