variance: Variance computation, usable in both S-PLUS and R

Description Usage Arguments Details Value See Also Examples

Description

A hybrid of S-PLUS and R definitions of the variance function.

Usage

1
variance(x, na.rm=TRUE, unbiased=FALSE)

Arguments

x

a numeric vector, matrix, or data.frame.

na.rm

a logical flag. If TRUE, NA values are removed prior to computation. Default: TRUE.

unbiased

a logical flag. If TRUE, the unbiased sample variance is returned. Default: FALSE.

Details

Allows the user to calculate the biased/unbiased variance of the input and provides the option to eliminate NA values as well.

Value

the sample variance of the input.

See Also

var.

Examples

1
2
3
4
5
set.seed(100)
x <- rnorm(100)
variance(x, unbiased=TRUE)
variance(x, unbiased=FALSE)
variance(c(x,rep(NA,30)), na.rm=TRUE)

ifultools documentation built on May 2, 2019, 4:48 p.m.