Similar to the base sweep function, but can be used for sparse matrices as well.
Source:R/sweep_sparse.R
sweep_sparse.Rd
Enables fast computations across columns or rows (margin=1 and 2 respectively) Only matrix, dgeMatrix, dgTMatrix, dgCMatrix, or dgRMatrix types are supported. adapted from https://stackoverflow.com/questions/55407656/r-sweep-on-a-sparse-matrix