I have one data.table with 2 columns ID and X, where X contains categorical values (a, b, c)
ID X
1 a
2 c
3 b
4 c
I would like to transform X into 3 binary columns where the column names are a, b and c
ID a b c
1 1 0 0
2 0 0 1
3 0 1 0
4 0 0 1
What will be a good way to do this? Thank you!