Automatically expanding an R factor into a collection of 1/0 indicator variables for every factor level December 25, 2022 by Tarik Use the model.matrix function: model.matrix( ~ Species - 1, data=iris )