View source: R/convert_one_hot_back.R
convert_one_hot_back | R Documentation |
convert_one_hot_back
is a function that...
convert_one_hot_back(df, prefix, vars, keep_dummies = FALSE)
XXX |
describe an input to function |
I think I got it from https://stackoverflow.com/questions/64230674/how-to-turn-one-hot-encoded-variables-to-a-single-factor-in-r
dat <- data.frame(season = as.factor(sample(1:4, 100, replace = TRUE))) dat2 <- model.matrix(~ season, dat) convert_one_hot_back(as_tibble(dat2), "season", c("season2", "season3", "season4")) %>% head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.