# R program to illustrate
# colMeans function
# Initializing a 3D array
x <- array(1:12, c(2, 3, 3))
# Getting the array representation
x
# Calling the colMeans() function
# for dims = 1, x[, 1, 1], x[, 2, 1], x[, 3, 1],
# x[, 1, 2] ... are columns
colMeans(x, dims = 1)
# for dims = 2, x[,,1], x[,,2], x[,,3]
# are columns
colMeans(x, dims = 2)