Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #' One-hot encode categorical variables.
- #'
- #' This function one-hot encodes categorical variables and binds the entire frame.
- #'
- #' @param data frame
- #' @param feature to encode
- #' @return hot-encoded data frame
- #'
- #' @export
- encode_and_bind <- function(frame, feature_to_encode) {
- res <- cbind(iris, one_hot(as.data.table(frame[[feature_to_encode]])))
- return(res)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement