Description Usage Arguments Details Examples
Create one hot encoder, that turns factor variables into dummy variables.
1 | encode_one_hot(vars = categoricals, sparse = FALSE)
|
vars |
Function or formula that returns selected columns from a data.frame. Alternatively, character vector of column names. |
sparse |
If true, return value will be a sparse Matrix of class dcgMatrix. Otherwise, regular data frame. |
If sparse is TRUE, this should be the last step of your preprocessing pipeline.
1 2 3 4 5 6 | df <- data.frame(A=c("a1","a1","a2","a3"), B=c("b1", "b2", "b3", "b4"), X=c(1,2,3,4))
prep <- encode_one_hot()
prep$fit(df)
prep$transform(df)
# or more succintly
prep$fit_transform(df)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.