variance(x, ...)
# S3 method for class 'numeric'
variance(x, ...)
# S3 method for class 'matrix'
variance(x, ...)
# S3 method for class 'numeric'
covariance(x, ...)
The implementation of variance()
for numeric variables coerces the input to
a vector then uses stats::var()
to compute the variance. This means that,
unlike stats::var()
, if variance()
is passed a matrix or a 2-dimensional
array, it will still return the variance (stats::var()
returns the
covariance matrix in that case).