R: Stacking Vectors and Matrixes

vec {fBasics} | R Documentation

## Stacking Vectors and Matrixes

### Description

Stacks either a lower triangle matrix or a matrix.

### Usage

    vec(x)
    vech(x)

### Arguments

`x` | a numeric matrix.

### Details

The function `vec` implements the operator that stacks a matrix as a column vector, to be more precise in a matrix with one column. vec(X) = (X11, X21, ..., XN1, X12, X22, ..., XNN).

The function `vech` implements the operator that stacks the lower triangle of a NxN matrix as an N(N+1)/2x1 vector: vech(X) =(X11, X21, X22, X31, ..., XNN), to be more precise in a matrix with one row.

### Examples

    ## Create Pascal Matrix:
       P = pascal(3)

    ## Stack a matrix
       vec(P)

    ## Stack the lower triangle
       vech(P)

[Package fBasics version 3042.89 Index]