dfm_sort: Sort a dfm by frequency of one or more margins

Description Usage Arguments Value Author(s) Examples

View source: R/dfm_sort.R

Description

Sorts a dfm by descending frequency of total features, total features in documents, or both.

Usage

1
dfm_sort(x, decreasing = TRUE, margin = c("features", "documents", "both"))

Arguments

x

Document-feature matrix created by dfm()

decreasing

logical; if TRUE, the sort will be in descending order, otherwise sort in increasing order

margin

which margin to sort on features to sort by frequency of features, documents to sort by total feature counts in documents, and both to sort by both

Value

A sorted dfm matrix object

Author(s)

Ken Benoit

Examples

1
2
3
4
dfmat <- dfm(data_corpus_inaugural)
head(dfmat)
head(dfm_sort(dfmat))
head(dfm_sort(dfmat, decreasing = FALSE, "both"))

koheiw/quanteda.core documentation built on Sept. 21, 2020, 3:44 p.m.