Skip to contents

Returns a transform that extracts a fixed-width substring from a string column. The result can be passed as the transform argument to il_compare() or il_block_on(), and composed with other transforms via il_transform(). On DuckDB and PostgreSQL, the computation is pushed into SQL.

Usage

il_substr(start, length)

Arguments

start

Integer start position (1-indexed).

length

Integer number of characters to extract.

Value

An il_column_transform closure.

Examples

tf <- il_substr(1, 3)
tf(c('Johnson', 'Smith', 'Lee'))
#> [1] "Joh" "Smi" "Lee"

# Use for blocking on the first 3 characters of a name
spec <- il_spec() |>
  il_block_on(last_name, .transform = il_substr(1, 3))