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

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".

Source

Bioconductor AnnotationDbi::unlist2

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

Herve Pages

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)
#> A.b A2 A.b B1 B2 B3 B4 B5 a a C1 C2 C3 C4 C.d C.e #> -4 2 7 3 2 1 0 -1 1 -2 2 1 0 -1 55 99
unlist_(x)
#> b A b B B B B B a a C C C C d e #> -4 2 7 3 2 1 0 -1 1 -2 2 1 0 -1 55 99
# annotation maps (as in AnnotationDbi objects egids2pbids <- list('10' = 'a', '100' = c('b', 'c'), '1000' = c('d', 'e')) egids2pbids
#> $`10` #> [1] "a" #> #> $`100` #> [1] "b" "c" #> #> $`1000` #> [1] "d" "e" #>
unlist(egids2pbids) # 1001, 1002, 10001 and 10002 are not real
#> 10 1001 1002 10001 10002 #> "a" "b" "c" "d" "e"
# Entrez ids but are the result of unlist() # mangling the names! unlist_(egids2pbids) # much cleaner! yes the names are not unique
#> 10 100 100 1000 1000 #> "a" "b" "c" "d" "e"
# but at least they are correct...