# NOT RUN {
x <- array(1:24, 2:4)
dim(x)
dim(expand_dims(x))
dim(expand_dims(x, 2))
dim(expand_dims(x, c(1,2)))
dim(expand_dims(x, c(1,-1)))
dim(expand_dims(x, 6)) # implicitly also expands dims 4,5
dim(expand_dims(x, 4:6))
# error, implicit expansion with negative indexes not supported
try(expand_dims(x, -6))
# supply them explicitly instead
dim(expand_dims(x, -(4:6)))
# }
Run the code above in your browser using DataLab