multisplit: Split elements belonging to multiple groups

Description Usage Arguments Value Author(s) Examples

View source: R/multisplit.R

Description

This is like split, except elements can belong to multiple groups, in which case they are repeated to appear in multiple elements of the return value.

Usage

1
multisplit(x, f)

Arguments

x

The object to split, like a vector.

f

A list-like object of vectors, the same length as x, where each element indicates the groups to which each element of x belongs.

Value

A list-like object, with an element for each unique value in the unlisted f, containing the elements in x where the corresponding element in f contained that value. Just try it.

Author(s)

Michael Lawrence

Examples

1
multisplit(1:3, list(letters[1:2], letters[2:3], letters[2:4]))

Example output

Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following object is masked from 'package:base':

    expand.grid

IntegerList of length 4
[["a"]] 1
[["b"]] 1 2 3
[["c"]] 2 3
[["d"]] 3

IRanges documentation built on Dec. 14, 2020, 2 a.m.