Learn R Programming

neuroim2 (version 0.8.5)

add_dim: 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 NeuroSpace,numeric add_dim(x, n)

Value

An object of the same class as x with the new dimension added.

Arguments

x

The NeuroSpace object

n

Numeric value specifying the size of the new dimension

Examples

Run this code
# 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

Run the code above in your browser using DataLab