ArrayAround {gapfill} | R Documentation |
Subset an Array with 4 dimensions
Description
Given an array data
with 4 dimensions,
a subset around the element with coordinates mp
("missing position") is extracted.
The size of the subset in all four directions
from mp
is specified by size
.
ArrayAroundRandom
returns a subset around a
random location in data
.
Usage
ArrayAround(data, mp, size)
ArrayAroundRandom(
data,
size = c(0L, 0L, 0L, 0L),
target = c("all", "missing", "observed"),
verbose = TRUE
)
Arguments
data |
Array with 4 dimensions. |
mp |
Integer vector of length 4
indexing an element in |
size |
Integer vector of length 4, that provides
the size of the subset in all four dimensions
(around |
target |
One of
|
verbose |
Logical vector of length 1.
If |
Value
Array with 4 dimensions corresponding to the specified subset.
The attribute mp
of the returned array is an integer vector
of length 4 giving mp
relative to the
returned array.
Note
When size = c(0, 0, 0, 0)
, the returned subset consists of one value
(the value of data
indexed with mp
.)
When mp
is near the boundaries of data
,
the returned subset may be smaller than indicated by the argument size
and the attribute mp
may indicate an element near the boundaries of the subset.
Author(s)
Florian Gerber, flora.fauna.gerber@gmail.com.
Examples
a <- array(1:16, c(2, 2, 2, 2))
ArrayAround(data = a, mp = c(1, 1, 1, 1), size = c(0, 0, 0, 0))
## returns the first element a[1,1,1,1]
ArrayAround(data = a, mp = c(2, 2, 2, 2), size = c(0, 0, 0, 0))
## returns the last element a[2,2,2,2]
ArrayAround(data = a, mp = c(1, 1, 1, 1), size = c(1, 0, 0, 0))
## returns a[1:2,1,1,1]
ArrayAround(data = a, mp = c(1, 1, 1, 1), size = c(1, 1, 1, 1))
## returns a
ArrayAroundRandom(a)
ArrayAroundRandom(a, size = c(1, 2, 1, 2))