# NOT RUN {
# 1D rray. Looks like a vector
# functions similar to a 1 column matrix
rray(c(1,2,3), dim = c(3))
# 3 rows, 4 cols
rray(c(1,2,3), dim = c(3, 4))
# 3x2x4 array
rray(1, dim = c(3, 2, 4))
# from a matrix
mat <- matrix(c(1, 2, 3, 4), ncol = 2)
rray(mat)
# from a matrix, with broadcasting
rray(mat, dim = c(2, 2, 3))
# reshape that matrix during creation
# (different from broadcasting)
rray(mat, dim = c(1, 4))
# from an array, with broadcasting
arr <- array(1, c(1, 2, 2))
rray(arr, c(3, 2, 2))
# with row names
rray(c(1, 2, 3), c(3, 2), dim_names = list(c("x", "y", "z"), NULL))
# }
Run the code above in your browser using DataLab