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"))
x | Document-feature matrix created by |
---|---|
decreasing | logical; if |
margin | which margin to sort on |
A sorted dfm matrix object
#> Document-feature matrix of: 6 documents, 9,357 features (93.8% sparse).head(dfm_sort(dtm))#> Document-feature matrix of: 6 documents, 9,357 features (93.8% sparse).head(dfm_sort(dtm, decreasing = FALSE, "both"))#> Document-feature matrix of: 6 documents, 9,357 features (96.3% sparse).