# NOT RUN {
# ---------------------------------------------------------------------------
# 2D example
x <- rray(1:6, c(3, 2))
x <- rray_set_row_names(x, c("r1", "r2", "r3"))
x <- rray_set_col_names(x, c("c1", "c2"))
# "counter clockwise" rotation turning the
# rows into columns
rray_rotate(x)
# "clockwise" by reversing the direction
rray_rotate(x, from = 2, to = 1)
# Rotate twice (180 degrees)
# Direction doesn't matter here, the following
# give the same result
rray_rotate(x, times = 2)
rray_rotate(x, from = 2, to = 1, times = 2)
# ---------------------------------------------------------------------------
# 3D example
x_3d <- rray_expand(x, 3)
# - Rotations on the (1, 3) axis plane
# - Dimensions go from (3, 2, 1) -> (1, 2, 3) in both cases
# - And the direction of how that happens is controlled
# by `from` and `to`
rray_rotate(x_3d, from = 1, to = 3)
rray_rotate(x_3d, from = 3, to = 1)
# }
Run the code above in your browser using DataLab