Learn R Programming

neuroim2 (version 0.8.5)

drop_dim: Drop a Dimension from an Object

Description

This function removes a specified dimension from a given object, such as a matrix or an array.

Usage

drop_dim(x, dimnum)

# S4 method for AxisSet2D,numeric drop_dim(x, dimnum)

# S4 method for AxisSet2D,missing drop_dim(x, dimnum)

# S4 method for AxisSet3D,numeric drop_dim(x, dimnum)

# S4 method for AxisSet3D,missing drop_dim(x, dimnum)

# S4 method for NeuroSpace,numeric drop_dim(x, dimnum)

# S4 method for NeuroSpace,missing drop_dim(x)

Value

An object of the same class as x with the specified dimension removed.

Arguments

x

An AxisSet3D object

dimnum

Numeric index of dimension to drop (optional)

Examples

Run this code
# Create a NeuroSpace object with dimensions (10, 10, 10)
x <- NeuroSpace(c(10, 10, 10), c(1, 1, 1))

# Drop the first dimension
x1 <- drop_dim(x, 1)

# Check the new dimensions
ndim(x1) == 2
dim(x1)[1] == 10

Run the code above in your browser using DataLab