Description Usage Arguments Details Value Examples
This function takes your dataframe of input variables and returns a new
dataframe (or matrix) with the categorical variables replaced by dummy
variables, using model.matrix
1 | create_model_matrix(dat, id = c(), matrix_out = TRUE, parallel = FALSE)
|
dat |
a tbl |
id |
character, naming the variable in dat which serves as the unique row identifier. If blank, will be created |
matrix_out |
logical. Should the result be a matrix ( |
parallel |
logical. If |
The function will only alter variables which are type factor
. Contrary
to how it may sound, this actually offers the user greater flexibility, for
two reasons: it allows you to keep character type variables intact, and it
forces you to think about the levels of each factor variable rather than
picking them straight from the input data
a matrix or a tbl, consisting of dummy columns with 0/1 indicators of membership in each factor level for each factor variable, and all other input variables unchanged.
1 2 3 | x <- simple_bin(iris,bins = 3)
create_model_matrix(x)
create_model_matrix(x,matrix_out = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.