Integer Encoder

integer_encoder(data, feature, as_factor = TRUE)

Arguments

data

Input data frame

feature

Unquoted form of the feature/column to encode

as_factor

Whether the feature data type should be kept as factor or pure integer

Value

Data frame with encoded feature column

Examples

set.seed(11) integer_encoder(iris[sample(1:150, 10),], Species)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.5 4.2 1.4 0.2 1 #> 2 6.8 3.2 5.9 2.3 3 #> 3 6.8 3.0 5.5 2.1 3 #> 4 5.5 3.5 1.3 0.2 1 #> 5 5.2 2.7 3.9 1.4 2 #> 6 7.7 3.8 6.7 2.2 3 #> 7 6.9 3.1 5.4 2.1 3 #> 8 5.9 3.0 4.2 1.5 2 #> 9 5.4 3.0 4.5 1.5 2 #> 10 5.8 2.6 4.0 1.2 2