quantile.lvec: Calculate the quantiles of an lvec

View source: R/partial_sort.R

quantile.lvecR Documentation

Calculate the quantiles of an lvec

Description

Calculate the quantiles of an lvec

Usage

## S3 method for class 'lvec'
quantile(
  x,
  probs = seq(0, 1, 0.25),
  names = TRUE,
  na.rm = TRUE,
  true_probs = FALSE,
  ...
)

Arguments

x

an object of type lvec.

probs

a numeric vector with probabilities ([0,1]).

names

add names to the result vector.

na.rm

remove missing values before calculating the quantiles

true_probs

add an attribute with the probabilities at the chosen pivots.

...

ignored.

Details

This function uses a more simple method than that used by the regular quantile method. It sorts the vector (using partial_sort for speed) and selects elements from x that correspond to the given probabilities. For example, when x has length of 11 and prob equal to 0.5, it selects the 6th element from the (partially) sorted x. For large enough vectors this is a reasonable approach.


djvanderlaan/lvec_stats documentation built on Oct. 4, 2022, 7:02 p.m.