findAssocs: Find Associations in a Term-Document Matrix

Description Usage Arguments Value Examples

View source: R/matrix.R

Description

Find associations in a document-term or term-document matrix.

Usage

1
2
3
4
## S3 method for class 'DocumentTermMatrix'
findAssocs(x, terms, corlimit)
## S3 method for class 'TermDocumentMatrix'
findAssocs(x, terms, corlimit)

Arguments

x

A DocumentTermMatrix or a TermDocumentMatrix.

terms

a character vector holding terms.

corlimit

a numeric vector (of the same length as terms; recycled otherwise) for the (inclusive) lower correlation limits of each term in the range from zero to one.

Value

A named list. Each list component is named after a term in terms and contains a named numeric vector. Each vector holds matching terms from x and their rounded correlations satisfying the inclusive lower correlation limit of corlimit.

Examples

1
2
3
data("crude")
tdm <- TermDocumentMatrix(crude)
findAssocs(tdm, c("oil", "opec", "xyz"), c(0.7, 0.75, 0.1))

Example output

Loading required package: NLP
$oil
     15.8   clearly      late    trying       who    winter  analysts      said 
     0.87      0.80      0.80      0.80      0.80      0.80      0.79      0.78 
  meeting     above emergency    market     fixed      that    prices agreement 
     0.77      0.76      0.75      0.75      0.73      0.73      0.72      0.71 
   buyers 
     0.70 

$opec
  meeting emergency      15.8  analysts    buyers     above      said   ability 
     0.88      0.87      0.85      0.85      0.83      0.82      0.82      0.80 
     they   prices. agreement 
     0.80      0.79      0.76 

$xyz
numeric(0)

tm documentation built on July 29, 2018, 5:03 p.m.