Why do you want a sparse matrix? For a dummy matrix you can also just use:
model.matrix(~ . + 0, data = df)
The 0 indicates no intercept and the . indicates that all categorical variables will be transformed. Be sure to set these variables as factors using as.factor() beforehand.