unlist2: A replacement for unlist() that does not mangle the names

Description Usage Arguments Details Author(s) See Also Examples

View source: R/unlist2.R

Description

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

Usage

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

Arguments

x, recursive, 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 unlist2 instead.

Author(s)

Hervé Pagès

See Also

unlist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  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)
  unlist2(x)

  library(hgu95av2.db)
  egids <- c("10", "100", "1000")
  egids2pbids <- mget(egids, revmap(hgu95av2ENTREZID))
  egids2pbids

  unlist(egids2pbids)   # 1001, 1002, 10001 and 10002 are not real
                        # Entrez ids but are the result of unlist()
                        # mangling the names!

  unlist2(egids2pbids)  # much cleaner! yes the names are not unique
                        # but at least they are correct...

jmacdon/AnnotationDbi documentation built on Oct. 22, 2021, 9:14 p.m.