lookup: Lookup and entry in an object with names

Description Usage Arguments Value See Also Examples

View source: R/lookup.R

Description

Lookup and entry in an object with names

Usage

1
lookup(x, dict = getOption("dictionary", abbreviations), missing = NA)

Arguments

x

string; one-element character vector

dict

object that has a names attribute that is used to look up the associated values.

missing

value to return if the value cannot be found, (DEFAULT: NA)

Looks up and returns the item(s) in dict matching the pattern given by x. If there is no matrching name found, the value provided in the missing argument is used.

It is not uncommon to set missing to

Value

one or more values looked up by name in the dictionary. There is no guarantee that there will be only one item returned per-lookup

See Also

extract which is used internally to match names

Examples

1
2
3
4
5
6
7
8
9
  dict <- 1:26 
  names(dict) <- letters
  dict <- searchable(dict) 
  dict <- ignore.case(dict)
  
  lookup( ignore.case('M'), dict )    # 13
  lookup( 'M', dict )                 # NA
  lookup( 'M', dict, 'M' )            # M
  

decisionpatterns/conformist documentation built on Nov. 4, 2019, 10:23 a.m.