Learn R Programming

quanteda (version 0.8.4-2)

docfreq: get the document frequency of a feature

Description

For a dfm-class object, returns the number of documents in which a feature in occurs greater than a given frequency threshold. The default is greater than zero, meaning that a feature occurs at least once in a document.

Usage

docfreq(object, threshold = 0)

## S3 method for class 'dfmDense,numeric': docfreq(object, threshold = 0)

## S3 method for class 'dfmDense,missing': docfreq(object, threshold = 0)

## S3 method for class 'dfmSparse,numeric': docfreq(object, threshold = 0)

## S3 method for class 'dfmSparse,missing': docfreq(object, threshold = 0)

## S3 method for class 'dfm,numeric': docfreq(object, threshold = 0)

## S3 method for class 'dfm,missing': docfreq(object, threshold = 0)

Arguments

object
a dfm-class document-feature matrix
threshold
numeric value of the threshold above which a feature will considered in the computation of document frequency. The default is 0, meaning that a feature's document frequency will be the number of documents in which it occurs greater than zero tim

Value

  • a numeric vector of document frequencies for each feature

Examples

Run this code
mydfm <- dfm(inaugTexts[1:2], verbose = FALSE)
docfreq(mydfm[, 1:20])

Run the code above in your browser using DataLab