var {rvec}R Documentation

Correlation, Variance and Covariance (Matrices), Including Rvecs

Description

Calculate correlations and variances, including when x or y is an rvec.

Usage

var(x, y = NULL, na.rm = FALSE, use)

Arguments

x

A numeric vector, matrix, data frame, or rvec().

y

NULL (default) or a vector, matrix, data frame, or rvec with compatible dimensions to x.

na.rm

Whether NAs removed before calculations.

use

Calculation method. See stats::var().

Details

To enable different behavior for rvecs and for ordinary vectors, the base R function stats::var() is turned into a generic, with stats::var() as the default.

For details on the calculations, see the documentation for stats::var().

Value

An rvec, if x or y is an rvec. Otherwise typically a numeric vector or matrix.

See Also

sd()

Examples

x <- rvec(cbind(rnorm(10), rnorm(10, sd = 20)))
x
var(x)

[Package rvec version 0.0.6 Index]