Learn R Programming

PSCBS (version 0.67.0)

weightedQuantile: Weighted Quantile Value

Description

Computes a weighted quantile of a numeric vector.

Usage

# S3 method for default
weightedQuantile(x, w, probs=c(0, 0.25, 0.5, 0.75, 1), na.rm=TRUE,
  method=c("wtd.quantile"), ...)

Value

Returns the weighted quantile.

Arguments

x

a numeric vector containing the values whose weighted quantile is to be computed.

w

a numeric vector of weights the same length as x giving the weights to use for each element of x. Negative weights are treated as zero weights. Default value is equal weight to all values.

probs

a numeric vector of quantiles in [0,1] to be retrieved.

na.rm

a logical value indicating whether NA values in x should be stripped before the computation proceeds, or not.

method

If "wtd.quantile", then an internal copy of Hmisc::wtd.quantile() is used. No other methods are currently supported.

...

Additional arguments passed to the estimator.

Author

Henrik Bengtsson

See Also

Internally the following functions may be used: quantile (if no weights are specified), or an internal copy of Hmisc::wtd.quantile(). For a weighted median estimator, weightedMedian of the matrixStats package.