drop_dim-methods: Drop a Dimension from an Object

drop_dimR Documentation

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 signature 'AxisSet2D,numeric'
drop_dim(x, dimnum)

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

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

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

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

## S4 method for signature 'NeuroSpace,missing'
drop_dim(x)

Arguments

x

A dimensioned object, such as a NeuroSpace object.

dimnum

An integer representing the index of the dimension to drop.

Value

An updated dimensioned object with the specified dimension removed.

Examples

# 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


bbuchsbaum/neuroim2 documentation built on Nov. 3, 2024, 9:31 a.m.