fm.groupbyR Documentation

Groupby on a FlashR vector.

Description

fm.sgroupby groups elements in a vector based on corresponding labels and applies FUN to the elements in each group. FUN is an aggregation operator.

Usage

fm.sgroupby(obj, FUN)

fm.groupby(obj, margin, factor, FUN)

Arguments

obj

a FlashR vector or matrix

FUN

an aggregation operator returned by fm.create.agg.op.

margin

the subscript which the function will be applied over. E.g., for a matrix, 1 indicates rows, 2 indicates columns.

factor

a FlashR factor vector that indicates how rows/columns in a matrix should be grouped.

Details

fm.groupby groups rows/columns of a matrix based on corresponding labels and applies FUN to the rows/columns in each group. FUN is an aggregation operator.

Value

fm.sgroupby returns a data frame, where the column val stores all of the unique values in the original data container, and the column agg stores the aggregate result of the corresponding value.

Author(s)

Da Zheng <dzheng5@jhu.edu>

Examples

vec <- fm.runif(100)
res <- fm.sgroupby(vec, "+")
mat <- fm.runif.matrix(100, 10)
fact <- fm.as.factor(as.integer(fm.runif(nrow(mat), min=0, max=3)))
res <- fm.groupby(mat, 2, fact, "+")