Drop a Dimension from an Object
Source:R/all_generic.R
, R/axis.R
, R/neurospace.R
drop_dim-methods.Rd
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)
Arguments
- x
A dimensioned object, such as a NeuroSpace object.
- dimnum
An integer representing the index of the dimension to drop.
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
#> [1] TRUE
dim(x1)[1] == 10
#> [1] TRUE