Learn R Programming

textir (version 1.8-5)

tfidf: Term Frequency * Inverse Document Frequency

Description

Convert a count matrix to the corresponding tfidf matrix.

Usage

tfidf(x, freq=FALSE)

Arguments

x
A matrix or simple_triplet_matrix.
freq
An indicator for whether x is already a frequency matrix.

Value

  • A matrix with entries $f_{ij} \log[ n/d_j ]$, where $f_{ij}$ is term-j frequency in document-i, and $d_j$ is the number of documents containing term-j.

See Also

freq

Examples

Run this code
## 20 important terms
data(congress109)
sort(sdev(tfidf(congress109Counts)), decreasing=TRUE)[1:20]

Run the code above in your browser using DataLab