apply_col.Rd
apply_col
: aggregate by col, return a [ngrp, ncol]
matrix
apply_row
: aggregate by row, return a [nrow, ngrp]
matrix
apply_col(mat, by, FUN = colMeans2, scale = 1, ...)
apply_row(mat, by, FUN = rowMeans2, scale = 1, ...)
matrix, [nrow, ncol]
integer vector, with the dim of [ntime]
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.
For example, setting the dimension of mat
is [ngrid, ntime]
,
if you want to aggregate by time, apply_row
should be used here;
if you want to aggregate by region (grids), apply_col
should be used.
This function also suits for big.matrix object.