Learn R Programming

s2dverification (version 2.5.0)

InsertDim: Adds A Dimension To A Matrix

Description

Add one dimension to the matrix var in position posdim with length lendim and which correspond to lendim repetitions of the var matrix.

Usage

InsertDim(var, posdim, lendim)

Arguments

var
Matrix to which a dimension should be added.
posdim
Position of the new dimension.
lendim
Length of the new dimension.

Value

Matrix with the added dimension.

Examples

Run this code
a <- array(rnorm(15), dim = c(3, 1, 5, 1))
print(dim(a))
print(dim(a[, , , ]))
print(dim(InsertDim(InsertDim(a[, , , ], 2, 1), 4, 1)))

Run the code above in your browser using DataLab