wt_stats | R Documentation |
Functions for computing basic weighted statistics. These functions are
designed to be strict, consistent, and useful within
dplyr::summarize()
.
wt_sum(x, wt)
wt_mean(x, wt)
wt_median(x, wt)
wt_quantile(x, wt, n)
x |
A logical or numeric vector. |
wt |
A numeric vector of weights the same length as |
n |
A numeric vector of length one (i.e., a number) giving the number
of equally sized groups to split |
If any NA
values are present in x
or wt
, these functions
will return NA
.
wt
must not contain any negative values. wt
may contain values
of zero but must not only contain values of zero.
For all except wt_quantile()
, a numeric vector of length
one.
For wt_quantile()
, a named numeric vector of length n - 1
unless any NA
values are present in x
or wt
, in which
case a numeric vector of length one (containing NA
) is returned.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.