Learn R Programming

matrixStats (version 0.12.2)

weightedVar: Weighted variance

Description

Computes a weighted variance of a numeric vector.

Usage

weightedVar(x, w, na.rm=FALSE, center=NULL, ...)

Arguments

x
a numeric vector containing the values whose weighted variance is to be computed.
w
a 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.
na.rm
a logical value indicating whether NA values in x should be stripped before the computation proceeds, or not. If NA, no che
center
Optional numeric scalar specifying the center location of the data. If NULL, it is estimated from data.
...
Not used.

Value

Missing values

Missing values are dropped at the very beginning, if argument na.rm is TRUE, otherwise not.

See Also

For the non-weighted variance, see var.