Last data update: 2014.03.03

R: Get a table of term frequencies
term.freqR Documentation

Get a table of term frequencies

Description

Get a table of term frequencies.

Usage

term.freq( d, 
		topN = 0, 
		percent = 0,
		sorted = c("none", "alpha", "freq"),
		decreasing = FALSE,
		useDocFreq = FALSE,		
		minFreq = 1 )

Arguments

d

The corpus from which term frequencies are calculated.

topN

If specified, only the 'topN' most frequent terms are returned. If more terms are requested than available, all terms are returned. If both 'topN' and 'percent' are zero, then all terms are returned.

percent

If specified, only the top 'percent' % most frequent terms are returned. If more terms are requested than available, all terms are returned. If both 'topN' and 'percent' are zero, then all terms are returned.

sorted

A string specifying how to sort the terms. 'none' for no sorting, 'alpha' for alphanumeric sorting, and 'freq' for sorting by frequency.

decreasing

If TRUE, terms are sorted in decreasing order, if FALSE, sorted ascending order.

useDocFreq

If TRUE, the returned frequencies are for the total number of documents in which the term occurs. If false, they are the total number of occurrences.

minFreq

Terms with *TOTAL* frequencies below this threshold will not be included in the output.

Value

A name vector of the term frequencies.

Examples

if(require(tm)){
data(crude)
term.freq(d=crude, percent=0, topN=10, minFreq=0,useDocFreq=FALSE,sorted="alpha", decreasing=TRUE)
}

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(DeducerText)
Loading required package: Deducer
Loading required package: ggplot2
Loading required package: JGR
Loading required package: rJava
Loading required package: JavaGD
Loading required package: iplots

Please type JGR() to launch console. Platform specific launchers (.exe and .app) can also be obtained at http://www.rforge.net/JGR/files/.


Loading required package: car
Loading required package: MASS


Note Non-JGR console detected:
	Deducer is best used from within JGR (http://jgr.markushelbig.org/).
	To Bring up GUI dialogs, type deducer().

Loading required package: tm
Loading required package: NLP

Attaching package: 'NLP'

The following object is masked from 'package:ggplot2':

    annotate

Loading required package: wordcloud
Loading required package: RColorBrewer
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DeducerText/term.freq.Rd_%03d_medium.png", width=480, height=480)
> ### Name: term.freq
> ### Title: Get a table of term frequencies
> ### Aliases: term.freq
> 
> ### ** Examples
> 
> if(require(tm)){
+ data(crude)
+ term.freq(d=crude, percent=0, topN=10, minFreq=0,useDocFreq=FALSE,sorted="alpha", decreasing=TRUE)
+ }
   the   that   said prices    oil    mln    its    for    and   OPEC 
   206     31     52     32     72     29     40     50     77     34 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>