Skip to contents

Converts a data frame with categorical and numeric columns into a numeric matrix, using one-hot encoding for categorical variables.

Usage

convert_to_numeric_matrix(df)

Arguments

df

A data frame.

Value

A numeric matrix.

Examples

df <- data.frame(a = c(1, 2), b = c("yes", "no"))
convert_to_numeric_matrix(df)
#>      a b_no b_yes
#> [1,] 1    0     1
#> [2,] 2    1     0