| wtd.mean {questionr} | R Documentation |
Compute the weighted mean or weighted variance of a vector.
wtd.mean(x, weights = NULL, normwt = "ignored", na.rm = TRUE)
x |
Numeric data vector |
weights |
Numeric weights vector. Must be the same length as |
normwt |
Only for |
na.rm |
if |
If weights is NULL, then an uniform weighting is applied.
These functions are exact copies of the wtd.mean and wtd.var
function from the wtd.stats package. They have been created by Frank Harrell, Department of Biostatistics,
Vanderbilt University School of Medicine, <f.harrell@vanderbilt.edu>.
mean,var, wtd.table and the survey package.
data(hdv2003) mean(hdv2003$age) wtd.mean(hdv2003$age, weights=hdv2003$poids) var(hdv2003$age) wtd.var(hdv2003$age, weights=hdv2003$poids)