make_dt_lookup_by_column: Lookup by column function factory.

View source: R/make_dt_lookup_by_column.R

make_dt_lookup_by_columnR Documentation

Lookup by column function factory.

Description

Build data.table implementation of lookup_by_column. We do this here as rqdatatable is a data.table aware package (and rquery is not).

Usage

make_dt_lookup_by_column(pick, result)

Arguments

pick

character scalar, name of column to control value choices.

result

character scalar, name of column to place values in.

Value

f_dt() function.

Examples


df = data.frame(x = c(1, 2, 3, 4),
                y = c(5, 6, 7, 8),
                choice = c("x", "y", "x", "z"),
                stringsAsFactors = FALSE)
make_dt_lookup_by_column("choice", "derived")(df)

# # base-R implementation
# df %.>% lookup_by_column(., "choice", "derived")
# # # data.table implementation (requies rquery 1.1.0, or newer)
# # df %.>% lookup_by_column(., "choice", "derived",
# #                          f_dt_factory = rqdatatable::make_dt_lookup_by_column)


WinVector/rqdatatable documentation built on Aug. 22, 2023, 3:25 p.m.