R/utility_functions.R

Defines functions DTMtoSparse

Documented in DTMtoSparse

#' convert a dtm from package tm to sparseMatrix from package Matrix
#' without converting it to full matrix.
#'@param dtm a document-term-matrix from package 'tm'
#'
#'@return a sparse dcgMatrix from package Matrix
DTMtoSparse <- function(dtm){

  return(Matrix::sparseMatrix(i = dtm$i, j = dtm$j, x = dtm$v, dimnames = dtm$dimnames, dims = dim(dtm)))
}

Try the MoMPCA package in your browser

Any scripts or data that you put into this service are public.

MoMPCA documentation built on Jan. 21, 2021, 5:09 p.m.