Learn R Programming

sjstats (version 0.10.2)

wtd_sd: Weighted statistics for variables

Description

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

Usage

wtd_sd(x, weights = NULL)

wtd_se(x, weights = NULL)

Arguments

x

(Numeric) vector or a data frame.

weights

Numeric vector of weights.

Value

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

Examples

Run this code
# NOT RUN {
wtd_sd(rnorm(n = 100, mean = 3),
       runif(n = 100))

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

# }

Run the code above in your browser using DataLab