mget2: enhanced mget

Description Usage Arguments Value TODO Author(s) Examples

Description

Enchanced mget to look up x in y. Changes in addition to mget include:
* Values can be sorted alphanumerically
* Since some keys have multiple values, this function returns all, just the first (hint; use first=TRUE, sort=TRUE), assuming that the first is the oldest, or all values collapsed into a single string.
* keys in x are allowed to be NA (hint: na.rm=FALSE)

Usage

1
2
  mget2(x, y, sort = TRUE, first = TRUE, na.rm = TRUE,
    collapse = NULL)

Arguments

x

a vector of keys, NA's allowed.

y

an env, or AnnDbBimap, or ProbeAnnDbBimap

sort

logical: if TRUE, then sort the values for each key

first

logical: if TRUE, then choose the first value for each key, after the optional sort

na.rm

logical: remove those keys that had no matches? if TRUE, a vector with no NA's will be returned. if FALSE, then return a list of key to value maps, possibly with NA's.

collapse

specify a character(1), eg “", "” to collapse multiple values
into a single character. Useful if you want to report all multi-mapping values. Note that this is ignored if first=TRUE, and that this will always return a character

Value

either a vector or list of values, depending on the value of na.rm, and collapse

TODO

provide more sorting options to choose the newest.

Author(s)

Mark Cowley, 2011-08-25

Examples

1
2
3
4
5
if( require(org.Hs.eg.db) ) {
  sym <- c("TP53", "INS", "EGFR", "MET", NA)
  mget2(sym, org.Hs.egSYMBOL2EG)
  mget2(sym, org.Hs.egSYMBOL2EG, na.rm=FALSE)
}

drmjc/macsR documentation built on May 15, 2019, 2:23 p.m.