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, 6 features (30.6% sparse). #> 6 x 6 sparse Matrix of class "dfmSparse" #> features #> docs fellow-citizens of the senate and house #> 1789-Washington 1 71 116 1 48 2 #> 1793-Washington 0 11 13 0 2 0 #> 1797-Adams 3 140 163 1 130 0 #> 1801-Jefferson 2 104 130 0 81 0 #> 1805-Jefferson 0 101 143 0 93 0 #> 1809-Madison 1 69 104 0 43 0head(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