Compute a weighted mean.
1 2 3 4
an object containing the values whose weighted mean is to be computed.
a numerical vector of weights the same length as
arguments to be passed to or from methods.
a logical value indicating whether
This is a generic function and methods can be defined for the first
x: apart from the default methods there are methods
for the date-time classes
"Date". The default method will work for
any numeric-like object for which
[, multiplication, division
sum have suitable methods, including complex vectors.
w is missing then all elements of
x are given the
same weight, otherwise the weights coerced to numeric by
as.numeric and normalized to sum to one (if possible: if
their sum is zero or infinite the value is likely to be
Missing values in
w are not handled specially and so give a
missing value as the result. However, zero weights are handled
specially and the corresponding
x values are omitted from the
For the default method, a length-one numeric vector.
1 2 3 4
We want your feedback!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.