Skip to contents

Convenience wrapper around an INVALUE lookup that pastes multiple vectors together into a composite label before reverse lookup. Mirrors [fputk()] on the invalue side, for INVALUE formats built with composite labels such as `fmap(paste(col1, col2, sep = "|"), codes)`.

Usage

finputk(..., invalue_name, sep = "|", na_as_string = FALSE)

Arguments

...

Vectors to paste together into a composite label. All vectors are recycled to a common length by [paste()].

invalue_name

Character. Name of a registered INVALUE format.

sep

Separator inserted between the pasted components (default `"|"`).

na_as_string

If `FALSE` (default), an `NA` in any component propagates to the composite label (restored to `NA_character_` after the [paste()] step) so the invalue's `missing_value` applies. If `TRUE`, the literal string `"NA"` produced by [paste()] is kept, which is useful when the invalue was built with composite labels via `fmap(paste(..., sep = "|"), values)`.

Value

A vector whose type depends on the invalue's `target_type`.

Details

The output type is determined by the stored invalue's `target_type` (numeric / integer → numeric, character → character, logical → logical).

See also

[finput()], [finputn()], [finputc()], [fputk()]

Examples

# Build an INVALUE keyed on two columns via paste()
finput(
  fmap(paste(c("A", "A", "B"), c(1, 2, 1), sep = "|"), c(10, 20, 30)),
  name = "ab_inv"
)
#> KS Invalue: ab_inv
#> Target Type: numeric 
#> Mappings:
#>   A|1 => 10
#>   A|2 => 20
#>   B|1 => 30

finputk(c("A", "A", "B"), c(1, 2, 1), invalue_name = "ab_inv")
#> [1] 10 20 30
# -> 10 20 30

fclear()
#> All formats cleared from library.