# lut

##### Lookup Tables

Create a lookup table.

##### Usage

`lut(outputs, ..., breaks=NULL, inputs=NULL)`

##### Arguments

- outputs
- Vector of output values
- ...
- Ignored.
- inputs
- Input values to which the output values are associated.
A factor or vector of the same length as
`outputs`

. Incompatible with`breaks`

. - breaks
- Breakpoints for the lookup table.
A numeric vector of length equal to
`length(outputs)+1`

.

##### Details

A lookup table is a function, mapping input values to output values.

The command `lut`

creates an object representing
a lookup table, which can then be used to control various behaviour
in the

The argument `outputs`

specifies the output values to which
input data values will be mapped. It should be a vector of
any atomic type (e.g. numeric, logical, character, complex) or factor
values.

Exactly one of the arguments `inputs`

and `breaks`

must be specified by name.

If `inputs`

is given, then it should be a vector or factor,
of the same length as `outputs`

. The entries of `inputs`

can be
any atomic type (e.g. numeric, logical, character, complex) or factor
values. The resulting lookup table associates the value `inputs[i]`

with the value `outputs[i]`

.

If `breaks`

is given, then it determines intervals
of the real number line
which are mapped to each output value. It should be a numeric vector,
of length at least 2, with entries that are in increasing order.
Infinite values are allowed. Any number in the range
between `breaks[i]`

and `breaks[i+1]`

will be mapped to the
value `outputs[i]`

.

The result is an object of class `"lut"`

.
There is a `print`

method for this class.
Some plot commands in the

The result is also a function `f`

which can be used to compute
the output value assigned to any input data value.
That is, `f(x)`

returns the output value assigned
to `x`

. This also works for vectors of input data values.

##### Value

- A function, which is also an object of class
`"lut"`

.

##### See Also

##### Examples

```
# lookup table for real numbers, using breakpoints
cr <- lut(factor(c("low", "medium", "high")), breaks=c(0,5,10,15))
cr
cr(3.2)
cr(c(3,5,7))
# lookup table for discrete set of values
ct <- lut(c(0,1), inputs=c(FALSE, TRUE))
ct(TRUE)
```

*Documentation reproduced from package spatstat, version 1.19-1, License: GPL (>= 2)*