dtm_remove_terms | R Documentation |
Remove terms from a Document-Term-Matrix and keep only documents which have a least some terms
dtm_remove_terms(dtm, terms, remove_emptydocs = TRUE)
dtm |
an object returned by |
terms |
a character vector of terms which are in |
remove_emptydocs |
logical indicating to remove documents containing no more terms after the term removal is executed. Defaults to |
a sparse Matrix as returned by sparseMatrix
where the indicated terms are removed as well as documents with no terms whatsoever
data(brussels_reviews_anno) x <- subset(brussels_reviews_anno, xpos == "NN") x <- x[, c("doc_id", "lemma")] x <- document_term_frequencies(x) dtm <- document_term_matrix(x) dim(dtm) x <- dtm_remove_terms(dtm, terms = c("appartement", "casa", "centrum", "ciudad")) dim(x) x <- dtm_remove_terms(dtm, terms = c("appartement", "casa", "centrum", "ciudad"), remove_emptydocs = FALSE) dim(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.