powered by
Transform a data frame into a matrix using one hot encoding.
as_model_matrix(df, intercept = FALSE)
A matrix.
A data frame.
Whether to have a column with all 1s. Default is FALSE.
1
FALSE
mat <- as_model_matrix(iris) str(mat)
Run the code above in your browser using DataLab