Sorts a dfm by descending frequency of total features, total features in documents, or both.
dfm_sort(x, decreasing = TRUE, margin = c("features", "documents", "both"))
Document-feature matrix created by
which margin to sort on
A sorted dfm matrix object
dtm <- dfm(data_corpus_inaugural) head(dtm)#> Document-feature matrix of: 6 documents, 9,357 features (93.8% sparse).head(dfm_sort(dtm))#> Error in get(".SigLength", envir = env): object '.SigLength' not foundhead(dfm_sort(dtm, decreasing = FALSE, "both"))#> Error in get(".SigLength", envir = env): object '.SigLength' not found