rmf_create_array | R Documentation |
Add rmf array class to object based on object dimensions
rmf_create_array( obj = NA, dim = NULL, kper = attr(obj, "kper"), dimlabels = attr(obj, "dimlabels") )
obj |
object to add class to |
dim |
the dim attribute for the array to be created; by default, dim(obj) is used |
kper |
integer vector specifying the stress periods in which the array is active. Used for defining boundary conditions. Defaults to |
dimlabels |
character vector specifying the labels of the dimensions; defaults to |
... |
subsetting a rmf_array
will return a rmf_array
as long as the object has a dim argument (i.e. has 2 or more dimensions). Atomic vectors are therefore never rmf_arrays
.
When l
is not specified when subsetting a rmf_4d_array
, a rmf_4d_array
will always be returned unless drop = TRUE
.
Furthermore, unlike subsetting arrays
, dimensions with length 1 will not be dropped unless the drop
argument is set to TRUE
.
either a rmf_2d_array
, a rmf_3d_array
or rmf_4d_array
object
# 2D r <- rmf_create_array(1:100, dim = c(10, 10)) r[,1] # returns rmf_2d_array r[,2:6] r[,1, drop = FALSE] # 3D r <- rmf_create_array(1:300, dim = c(10, 10, 3), kper = 1:2) r[,6,2] # 1D - vector # returns 2D array r[,,1] r[,1,] # returns 3D array r[,,1, drop = FALSE] r[,,1:2] # 4D r <- rmf_create_array(1:600, dim = c(10, 10, 3, 2)) # returns 4D r[,,1,] # l not specified r[,,,1, drop = FALSE] # returns 3D r[,,,1] # returns 2D r[,,1,1] # dimensions of length 1 are not automatically dropped r <- rmf_create_array(1:100, dim = c(1, 10, 3)) r[,,1] # 1st dimension not dropped r[,,1, drop = TRUE] # 1st dimension dropped
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.