rray_reverse: Reverse elements along axes

View source: R/reverse.R

rray_reverseR Documentation

Reverse elements along axes

Description

rray_reverse() reverses the order of the elements of x along one or more axes.

Usage

rray_reverse(x, ..., axes)

Arguments

x

An array.

...

These dots are for future extensions and must be empty.

axes

The axes to reverse along, given by position or by title.

Details

Names on a reversed axis move with the data. Every other axis keeps its names untouched. The titles of x are kept.

Value

An array with the same type and dimensions as x.

Examples

rray_reverse(1:5, axes = 1)

x <- matrix(1:6, nrow = 2, dimnames = list(c("r1", "r2"), c("a", "b", "c")))

# Reverse the rows, names move with the data
rray_reverse(x, axes = 1)

# Reverse the columns
rray_reverse(x, axes = 2)

# Reverse both axes
rray_reverse(x, axes = c(1, 2))

# Reverse the columns, by title
y <- rray_set_titles(x, c("row", "col"))
rray_reverse(y, axes = "col")

rray documentation built on Nov. 17, 2026, 5:07 p.m.