Description
Ran into an issue with fitting coherence() into my workflow with external term co-occurrence matrices, figured it out now but letting you know that the documentation could reflect this:
The term co-occurrence matrix, e.g, a Matrix::sparseMatrix or base::matrix, serving as the reference to calculate coherence metrics. Please note that a memory efficient version of the tcm is assumed as input with all entries in the lower triangle (excluding diagonal) set to zero (see, e.g., create_tcm).
coherence() actually works properly with Matrix class dsCMatrix (which is what is produced in the example workflow), but does not work with class dgCMatrix with empty lower triangle. This is because
tcm = as.matrix(tcm[top_terms_tcm, top_terms_tcm])
in coherence() doesn't produce the wanted result with lower-triangle empty dgCMatrix. However, a symmetrical dgCMatrix produces the same results as a dsCMatrix.
Given dgCMatrix is the default for converting to sparseMatrix with Matrix, it might be nice to note this in the documentation.