lookup_dt: Perform Table Lookup and Merge

View source: R/lookup_dt.R

lookup_dtR Documentation

Perform Table Lookup and Merge

Description

Executes a lookup operation between two data.tables by matching on common key columns. The lookup is conducted on key columns (which are factors or integers starting from 1) and maps each unique combination to a corresponding index. The lookup values are then merged into the main table or returned separately based on the merge parameter.

Usage

lookup_dt(
  tbl,
  lookup_tbl,
  merge = TRUE,
  exclude_col = NULL,
  check_lookup_tbl_validity = FALSE
)

Arguments

tbl

The main data.table on which the lookup operation is performed.

lookup_tbl

A data.table containing the lookup values, with key columns matching those in tbl.

merge

Logical. If TRUE, the lookup results are merged into tbl; if FALSE, only the lookup results are returned.

exclude_col

A character vector specifying column names to exclude from the lookup keys.

check_lookup_tbl_validity

Logical. If TRUE, validates the structure of lookup_tbl.

Value

A data.table. When merge = TRUE, tbl is returned with additional lookup columns; otherwise, a data.table containing only the lookup results is returned.


ChristK/CKutils documentation built on April 11, 2025, 10:11 p.m.