Skip to contents

Creates new integer columns by extracting specific digits from numeric columns. This function emulates a feature engineering technique often used in machine learning.

Usage

plant_decimals_extract(barn_obj, numeric_sufix = "_num", from = 1, to = 10)

Arguments

barn_obj

A barn object, created by barn().

numeric_sufix

The suffix used to identify numeric columns to process. Defaults to "_num".

from

The starting digit position to extract (e.g., 1 for the first decimal place). Defaults to 1.

to

The ending digit position to extract (e.g., 9 for the ninth decimal place). Defaults to 9.

Value

The modified barn_obj with the transformed combined data frame.

Examples

df <- tibble::tibble(x_num = c(1.234, 5.678, NA))
b <- barn(df) |> plant_decimals_extract(from = 1, to = 3)
harvest(b)[[1]]
#> # A tibble: 3 × 4
#>   x_num x_d1_num x_d2_num x_d3_num
#>   <dbl>    <dbl>    <dbl>    <dbl>
#> 1  1.23        2        3        4
#> 2  5.68        6        7        8
#> 3 NA          -1       -1       -1