Skip to contents

This function adds a new dimension to a given object, such as a matrix or an array.

Usage

add_dim(x, n)

# S4 method for NeuroSpace,numeric
add_dim(x, n)

Arguments

x

A dimensioned object, such as a matrix, an array, or a NeuroSpace object.

n

An integer representing the size of the dimension to add.

Value

An updated dimensioned object with the new dimension added.

Examples

# Create a NeuroSpace object
x <- NeuroSpace(c(10, 10, 10), c(1, 1, 1))

# Add a new dimension with size 10
x1 <- add_dim(x, 10)

# Check the new dimension
ndim(x1) == 4
#> [1] TRUE
dim(x1)[4] == 10
#> [1] TRUE