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

unlist_

Flatten a List Conserving Names


Description

unlist2 is a replacement for base::unlist that does not mangle the names.

Usage

unlist_(x, recursive = TRUE, use.names = TRUE, what.names = "inherited")

Arguments

x

See ?unlist.

recursive

See ?unlist.

use.names

See ?unlist.

what.names

"inherited" or "full".

Details

Use this function if you don't like the mangled names returned by the standard unlist function from the base package. Using unlist with annotation data is dangerous and it is highly recommended to use unlist_ instead.

Author(s)

Herve Pages

Source

Bioconductor AnnotationDbi::unlist2

Examples

x <- list(A=c(b=-4, 2, b=7), B=3:-1, c(a=1, a=-2), C=list(c(2:-1, d=55), e=99))
unlist(x)
unlist_(x)

# annotation maps (as in AnnotationDbi objects
egids2pbids <- list('10' = 'a', '100' = c('b', 'c'), '1000' = c('d', 'e'))
egids2pbids

unlist(egids2pbids)   # 1001, 1002, 10001 and 10002 are not real
                      # Entrez ids but are the result of unlist()
                      # mangling the names!
unlist_(egids2pbids)  # much cleaner! yes the names are not unique
                      # but at least they are correct...

pkgmaker

Development Utilities for R Packages

v0.32.2
GPL (>= 2)
Authors
Renaud Gaujoux [aut, cre]
Initial release
2020-10-20

We don't support your browser anymore

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