Learn R Programming

quanteda (version 0.9.9-50)

topfeatures: list the most frequent features

Description

List the most (or least) frequently occuring features in a dfm.

Usage

topfeatures(x, n = 10, decreasing = TRUE, ci = 0.95)

Arguments

x
the object whose features will be returned
n
how many top features should be returned
decreasing
If TRUE, return the n most frequent features, if FALSE, return the n least frequent features
ci
confidence interval from 0-1.0 for use if dfm is resampled

Value

A named numeric vector of feature counts, where the names are the feature labels.

Examples

Run this code
# most frequent features
topfeatures(dfm(corpus_subset(data_corpus_inaugural, Year > 1980), verbose = FALSE))
topfeatures(dfm(corpus_subset(data_corpus_inaugural, Year > 1980), 
            remove = stopwords("english"), verbose = FALSE))
            
# least frequent features
topfeatures(dfm(corpus_subset(data_corpus_inaugural, Year > 1980), verbose = FALSE), 
            decreasing = FALSE)

Run the code above in your browser using DataLab