variance: Variance

View source: R/variance.r

varianceR Documentation

Variance

Description

Variance

Usage

variance(x, sample = FALSE, na.rm = FALSE)

Arguments

x

numerical vector.

sample

logical. Compute sample variance or apply correction?

na.rm

logical. Should missing values be removed?

Value

The variance, with ou whithout sample correction.

Examples

# variance of the height in EUR2170 data
variance(EUR2170$height, sample = TRUE)
# adults only
he <- subset(EUR2170, age > 20, "height")
variance(he, sample = TRUE)
# males and females separately
heM <- subset(EUR2170, age > 20 & sex == "M", "height")
heF <- subset(EUR2170, age > 20 & sex == "F", "height")
variance(heM, sample = TRUE)
variance(heF, sample = TRUE)

HervePerdry/M1SP documentation built on Dec. 16, 2024, 8:19 p.m.