CST_ReorderDims: Reorder the dimensions of an s2dv_cube

View source: R/CST_ReorderDims.R

CST_ReorderDimsR Documentation

Reorder the dimensions of an s2dv_cube

Description

Reorder the dimensions of an s2dv_cube. The order can be provided either as indices or the dimension names. If the order is dimension names, the function looks for names(dim(x)). If it doesn't exist, the function checks if attributes "dimensions" exists; this attribute is in the objects generated by Load().

Usage

CST_ReorderDims(x, order)

Arguments

x

An array of which the dimensions to be reordered.

order

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

Value

An s2dv_cube which has the data and information as parameter 'x', but with different dimension order.

See Also

Reorder

Examples

# Example with sample data:
# Check original dimensions and coordinates
lonlat_temp$exp$dims
names(lonlat_temp$exp$coords)
# Reorder the s2dv_cube
new_order <- c("dataset", "member", "sdate", "ftime", "lon", "lat")
res <- CST_ReorderDims(x = lonlat_temp$exp, order = new_order)
# Check new dimensions and coordinates
dim(res$data)
res$dims
names(res$coords)


CSTools documentation built on March 17, 2026, 5:07 p.m.