Learn R Programming

ribiosUtils (version 1.7.7)

invertList: Invert the names and elements of a list

Description

Invert the names and elements of a list

Usage

invertList(inputList, simplify = FALSE)

Value

A list with values from the input becoming names and vice versa. When simplify=TRUE and there are no duplicated names, a named character vector is returned instead.

Arguments

inputList

a list, other classed (e.g. named vectors) will be converted to lists

simplify

Logical, if yes and if no duplicated names, return a vector

Examples

Run this code
myList <- list("A"=c("a", "alpha"), "B"=c("b", "Beta"), "C"="c")
invertList(myList)
invertList(myList, simplify=TRUE)

Run the code above in your browser using DataLab