Skip to contents

This function calculates the population standard deviation of a numeric vector. Unlike the default sd() function in R, which computes the sample standard deviation, this function adjusts the calculation to use n instead of n-1 in the denominator.

Usage

sd_desc(x, na.rm = FALSE)

Arguments

x

A numeric vector containing the data.

na.rm

A logical value indicating whether to remove missing values (NA) before computation. Default is FALSE.

Value

A numeric value representing the population standard deviation of x.

See also

var_desc for computing the population variance.

Examples

data <- c(10, 20, 30, 40, 50, NA)
sd_desc(data)          # Compute standard deviation including NA (returns NA)
#> [1] NA
sd_desc(data, na.rm = TRUE)  # Compute standard deviation ignoring NA
#> [1] 14.14214