R code to convert a data frame of factor variables into a sparse matrix.