imget: Case-insensitive mget()

imgetR Documentation

Case-insensitive mget()

Description

Case-insensitive mget()

Usage

imget(
  x,
  envir = as.environment(-1L),
  mode = "any",
  ifnotfound = NA,
  inherits = FALSE,
  verbose = FALSE,
  ...
)

Arguments

x

character vector of object names.

envir, mode, ifnotfound, inherits

arguments are passed to base:mget().

Details

This function is a lightweight wrapper around base::mget() (and generics) that intends to allow case-insensitive matching. It does so by converting all keys to lowercase, matching lowercase input to these lowercase keys, then using the original keys in native base::mget().

One small change from base::mget() is the default argument ifnotfound=NA.

This function secretly runs mget() using the unique lowercase input values x, to reduce the number of queries. This implementation is designed to help with extremely long and potentially highly duplicated input values in x, in which case the change greatly reduces the time to return results.

Note: This function returns the first matching lowercase key, with the direct assumption that keys will not be duplicated after converting to lowercase. Should this assumption become a problem, please provide feedback and we will change the method accordingly.

Note: For unknown reasons, the R method dispatch was not behaving properly for objects of class "AnnDbBimap", presumably because the generic functions AnnotationDbi::ls() and AnnotationDbi::mget() were written for class "Bimap". So when the input envir class contains "Bimap" the direct function AnnotationDbi::keys() is called, and if it fails for some reason, AnnotationDbi::ls() is called, thes AnnotationDbi::mget() is called, otherwise the generic ls() or mget() is called.

Value

named list of objects found, or NA for objects that are not found.


jmw86069/genejam documentation built on Sept. 19, 2022, 1:53 p.m.