apply_3d.Rd
NA values will be removed automatically
apply_3d(
array,
dim = 3,
FUN = rowMeans2,
by = NULL,
scale = 1,
na.rm = TRUE,
...
)
A 3d array
giving the subscripts to split up data by.
function, should only be row applied function, e.g. matrixStats::rowMeans2
,
matrixStats::rowMins
, matrixStats::rowRanges
.
Because 3d array will be convert to matrix first, with the aggregated dim in
the last dimension.
If not provided (NULL
), the aggregated dim will be disappear.
For example, daily precipitation [nrow, ncol, 31-days]
aggregate into
monthly [nrow, ncol]
.
If provided, by
should be equal to the aggregated dim
.
For example, daily precipitation [nrow, ncol, 365-days]
aggregate into
monthly [nrow, ncol, 12-months]
. In that situation, by
should be equal
to 365, and be format(date, '%Y%m')
.
in the same length of by
, or a const value,
value_returned
= FUN(x)*scale
. This parameter is designed for converting
monthly to yearly, meanwhile multiply days in month.
Currently, same group should have the same scale factor. Otherwise, only the
first is used.