Как насчет использования model.matrix ()?
> binom <- data.frame(data=runif(1e5),type=sample(0:4,1e5,TRUE))
> head(binom)
data type
1 0.1412164 2
2 0.8764588 2
3 0.5559061 4
4 0.3890109 3
5 0.8725753 3
6 0.8358100 1
> inds <- model.matrix(~ factor(binom$type) - 1)
> head(inds)
factor(binom$type)0 factor(binom$type)1 factor(binom$type)2 factor(binom$type)3 factor(binom$type)4
1 0 0 1 0 0
2 0 0 1 0 0
3 0 0 0 0 1
4 0 0 0 1 0
5 0 0 0 1 0
6 0 1 0 0 0