vec: Stacks a Matrix using matrix operator "vec"

Description Usage Arguments Value Note References See Also Examples

View source: R/vec.R

Description

Returns a column vector that stacks the columns of A, a m x n matrix.

Usage

1
vec(A, use.Names = TRUE)

Arguments

A

A matrix with m rows and n columns.

use.Names

Logical. If TRUE, the names of A are taken to be names of the stacked matrix. Default: TRUE.

Value

A vector with mn elements.

Note

  1. Unlike other 'vec()' functions on CRAN, matrixNormal versions inherit names from matrices to their vectorized forms.

  2. vec() was adapted from Frederick Novomestky's matrixcalc. This function is edited so that it can take dimension names and return the matrix as a vector.

  3. These functions were used as accessories used in matrixNormal functions.

References

Magnus, J. R. and H. Neudecker (1999). Matrix Differential Calculus with Applications in Statistics and Econometrics. Second Edition, John Wiley, ed.

See Also

Other matrix: special.matrix, tr()

Examples

1
2
3
4
5
6
7
M <- matrix(c(4, 5, 6, 7, 8, 9), nrow = 3)
M
# Compare vec from \pkg{matrixcalc} and new function.
matrixcalc::vec(M)
vec(M)
# The names are rownames(M):colnames(M) in that order.
# Very similar to matrixcalc but dimension names are different.

phargarten2/matrixNormal documentation built on Dec. 31, 2021, 12:06 a.m.