apply_col | R Documentation |
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, ...)
mat |
matrix, |
by |
integer vector, with the dim of |
scale |
in the same length of |
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.
mat <- matrix(rnorm(4 * 6), 4, 6)
mat_bycol <- apply_col(mat, c(1, 1, 2, 2), colMeans)
mat_byrow <- apply_row(mat, c(1, 1, 2, 2, 3, 3), rowMeans)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.