Learn R Programming

s2dv (version 1.3.0)

Reorder: Reorder the dimension of an array

Description

Reorder the dimension order of a multi-dimensional array

Usage

Reorder(data, order)

Value

An array which has the same values as parameter 'data' but with different dimension order.

Arguments

data

An array of which the dimension to be reordered.

order

A vector of indices or character strings indicating the new order of the dimension.

Examples

Run this code
 dat1 <- array(c(1:30), dim = c(dat = 1, sdate = 3, ftime = 2, lon = 5))
 print(dim(Reorder(dat1, c(2, 1, 4, 3))))
 print(dim(Reorder(dat1, c('sdate', 'dat', 'lon', 'ftime'))))
 dat2 <- array(c(1:10), dim = c(2, 1, 5))
 print(dim(Reorder(dat2, c(2, 1, 3))))

Run the code above in your browser using DataLab