(How to convert data frame into transaction form-basket/normalized form in apriori algorithm)
To create a sparse matrix:
regMat <- matrix(0, nrow=5, ncol=5)
regMat[cbind(c(3,2),c(1,5,4))] <- round(runif(5,0,25))
B <- Matrix(regMat, sparse = TRUE).
As you can see this is for a simple data frame with only 5*5 cells,but I hope this helps!!