add_dim-methods: Add a Dimension to an Object

add_dimR Documentation

Add a Dimension to an Object

Description

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 signature '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
dim(x1)[4] == 10


bbuchsbaum/neuroim2 documentation built on Jan. 2, 2025, 3:38 p.m.