CST_InsertDim {CSTools} | R Documentation |
Add a named dimension to an object of class s2dv_cube
Description
Insert an extra dimension into an array at position 'posdim' with length
'lendim'. The array in data
repeats along the new dimension.
The dimensions, coordinates and attributes are modified accordingly.
Usage
CST_InsertDim(data, posdim, lendim, name, values = NULL)
Arguments
data |
An object of class |
posdim |
An integer indicating the position of the new dimension. |
lendim |
An integer indicating the length of the new dimension. |
name |
A character string indicating the name for the new dimension. |
values |
A vector containing the values of the new dimension and any relevant attributes. If NULL, a sequence of integers from 1 to lendim will be added. |
Value
An object of class s2dv_cube
with similar data, coordinates and
attributes as the data
input, but with an additional dimension.
Author(s)
Agudetse Roures Victoria, victoria.agudetse@bsc.es
See Also
Examples
#Example with sample data:
# Check original dimensions and coordinates
lonlat_temp$exp$dims
names(lonlat_temp$exp$coords)
# Add 'variable' dimension
exp <- CST_InsertDim(lonlat_temp$exp,
posdim = 2,
lendim = 1,
name = "variable",
values = c("tas"))
# Check new dimensions and coordinates
exp$dims
exp$coords$variable