mvl_group: Group identical rows

View source: R/RMVL.R

mvl_groupR Documentation

Group identical rows

Description

This function groups identical rows. The result is formatted as two vectors stretch_index and index Vector index contains stretches of indices with identical rows. Vector stretch_index describes stretches as stretch_index[i] to stretch_index[i+1]-1 This allows fast iteration over indices without creating excessive numbers of R objects when group sizes are small.

Usage

mvl_group(L, indices = NULL)

Arguments

L

list of vector like MVL_OBJECTs

indices

list of indices into objects to group. If absent or NULL it is assumed to be from 1 to the length of the object.

Value

A list of groups and group stretches

See Also

mvl_group_lapply, mvl_hash_vectors, mvl_find_matches, mvl_order_vectors, mvl_find_matches, mvl_indexed_copy, mvl_merge

Examples

## Not run: 
Mtmp<-mvl_open("tmp_a.mvl", append=TRUE, create=TRUE)
mvl_write_object(Mtmp, data.frame(x=rep(c("a", "b"), 50), y=(1:100)/5), "df1")
Mtmp<-mvl_remap(Mtmp)
df1<-Mtmp["df1", ref=TRUE]
G<-mvl_group(list(df1[,"x",ref=TRUE], df1[,"y", ref=TRUE]))
mvl_group_lapply(G, function(idx) { return(sum(df1[idx, "y"]))})

## End(Not run)

RMVL documentation built on Nov. 2, 2023, 6:09 p.m.

Related to mvl_group in RMVL...