Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

reverseSplit

A function to reverse the role of names and values in a list.


Description

Given a list with names x and values in a set y this function returns a list with names in y and values in x.

Usage

reverseSplit(inList)

Arguments

inList

A named list with values that are vectors.

Details

First the list is unrolled to provide a two long vectors, names are repeated, once for each of their values. Then the names are split by the values.

This turns out to be useful for inverting mappings between one set of identifiers and an other.

Value

A list with length equal to the number of distinct values in the input list and values from the names of the input list.

Author(s)

R. Gentleman

See Also

Examples

l1 = list(a=1:4, b=c(2,3), d=c(4,5))
 reverseSplit(l1)

Biobase

Biobase: Base functions for Bioconductor

v2.50.0
Artistic-2.0
Authors
R. Gentleman, V. Carey, M. Morgan, S. Falcon
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.