Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

weighted.sd

Weighted standard deviation


Description

This is a basic weighted standard deviation function, mainly for internal use with sumtable. For a more fully-fledged weighted SD function, see Hmisc::wtd.var, although it uses a slightly differend degree-of-freedom correction.

Usage

weighted.sd(x, w, na.rm = TRUE)

Arguments

x

A numeric vector.

w

A vector of weights. Negative weights are not allowed.

na.rm

Set to TRUE to remove indices with missing values in x or w.

Examples

x <- c(1, 1, 2, 3, 4, 4, 4)
w <- c(4, 1, 3, 7, 0, 2, 5)
weighted.sd(x, w)

vtable

Variable Table for Variable Documentation

v1.3.1
MIT + file LICENSE
Authors
Nick Huntington-Klein [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.