This function adds a new dimension to a given object, such as a matrix or an array.
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.
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
#> [1] TRUE
dim(x1)[4] == 10
#> [1] TRUE