I want to one-hot encode in R through tidyverse, and not use packages such as caret, mltools, etc.
## Load vcd package
library(vcd)
## Load Arthritis dataset (data frame)
data(Arthritis)
Arthritis[1:5, ][2:5]
Treatment Sex Age Improved
1 Treated Male 27 Some
2 Treated Male 29 None
3 Treated Male 30 None
4 Treated Male 32 Marked
5 Treated Male 46 Marked
Is there an easy way to do this in tidyverse where I keep n-1 of the values for each categorical column? For example Sex is binary in this dataset so I would only need a one-hot encoded column for either Male or Female. The age feature would be ignored.