fm.groupby | R Documentation |
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.
fm.sgroupby(obj, FUN) fm.groupby(obj, margin, factor, FUN)
obj |
a FlashR vector or matrix |
FUN |
an aggregation operator returned by |
margin |
the subscript which the function will be applied over.
E.g., for a matrix, |
factor |
a FlashR factor vector that indicates how rows/columns in a matrix should be grouped. |
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.
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.
Da Zheng <dzheng5@jhu.edu>
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, "+")