All the ways to do one-hot encoding

julia> using StatsBase

julia> x = ["a", "b", "c", "a", "b", "d"]
6-element Vector{String}:
 "a"
 "b"
 "c"
 "a"
 "b"
 "d"

julia> indicatormat(x)
4ร—6 Matrix{Bool}:
 1  0  0  1  0  0
 0  1  0  0  1  0
 0  0  1  0  0  0
 0  0  0  0  0  1

but normally I do your option 1 :smiley: :

julia> df = DataFrame(x=x)
6ร—1 DataFrame
 Row โ”‚ x
     โ”‚ String
โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   1 โ”‚ a
   2 โ”‚ b
   3 โ”‚ c
   4 โ”‚ a
   5 โ”‚ b
   6 โ”‚ d

julia> select(df, [:x => ByRow(isequal(v))=> Symbol(v) for v in unique(df.x)])
6ร—4 DataFrame
 Row โ”‚ a      b      c      d
     โ”‚ Bool   Bool   Bool   Bool
โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   1 โ”‚  true  false  false  false
   2 โ”‚ false   true  false  false
   3 โ”‚ false  false   true  false
   4 โ”‚  true  false  false  false
   5 โ”‚ false   true  false  false
   6 โ”‚ false  false  false   true

(DataConvenience.jl is nice :+1:)