# NOT RUN {
x <- rray(1:10, c(5, 2))
# Reduce the number of rows to 1,
# summing along the way
rray_sum(x, 1)
# Reduce the number of columns to 1,
# summing along the way
rray_sum(x, 2)
# Reduce along all axes, but keep dimensions
rray_sum(x)
# Column-wise proportions
x / rray_sum(x, 1)
# Row-wise proportions
x / rray_sum(x, 2)
# Reducing over multiple axes
# This reduces over the rows and columns
# of each mini-matrix in the 3rd dimension
y <- rray(1:24, c(2, 3, 4))
rray_sum(y, c(1, 2))
# }
Run the code above in your browser using DataLab