Learn R Programming

sjstats (version 0.2.0)

wtd_sd: Weighted standard deviation for variables

Description

Compute weighted standard deviation for a variable or for all variables of a data frame.

Usage

wtd_sd(x, weights = NULL)

Arguments

x
(Numeric) vector or a data frame.
weights
Numeric vector of weights.

Value

The weighted standard deviation of x, or for each variable if x is a data frame.

Examples

Run this code
wtd_sd(rnorm(n = 100, mean = 3),
       runif(n = 100))

data(efc)
wtd_sd(efc[, 1:3], runif(n = nrow(efc)))

Run the code above in your browser using DataLab