I am trying to create a matrix mulptiplication with sparse matrix and with the package called quanteda, utilising data.table package, related to this thread here. So
require(quanteda)
mytext <- c("Let the big dogs hunt", "No holds barred", "My child is an honor student")
myMatrix <-dfm(mytext, ignoredFeatures = stopwords("english"), stem = TRUE) #a data.table
as.matrix(myMatrix) %*% transpose(as.matrix(myMatrix))
how can you get the matrix multiplication working here with quanteda package and sparse matrices?
This works just fine:
No need to coerce to a dense matrix using
as.matrix()
. Note that it is no longer a "dfmSparse" object because it's no longer a matrix of documents by features.