R: Look Up a Value In a Reference Vector

Lookup {DescTools} | R Documentation

## Look Up a Value In a Reference Vector

### Description

`Lookup` searches the positions of (first) matches of the argument x in its second argument idx and returns the according values from ret.

### Usage

    Lookup(x, ref, val)

### Arguments

`x` | vector: the values to be matched. Long vectors are supported.
`ref` | vector: the values to be matched. Long vectors are supported.
`val` | vector: the values to be returned.

### Details

This function is wrapping the function `match` allowing to pass a vector from which the found elements should be returned. This is often used in a code lookup situation and might be simpler than using `match` or `merge`.

### Value

A vector of the same length as `x` giving the elements in `ret` at the position in `idx` of the first match if there is a match. If there's no match `NA` will be returned.

### Author(s)

Andri Signorell <andri@signorell.net>

### See Also

`match`, `merge`

### Examples

    x <- c("a", "h", "b")
    z <- LETTERS
    Lookup(x, letters, z)

[Package DescTools version 0.99.25 Index]