R.temis (version 0.1.3)

cooc_terms: cooc_terms

Description

Show terms that are the most associated (positively or negatively) with a reference term.

Usage

cooc_terms(
  dtm,
  term,
  variable = NULL,
  p = 0.1,
  n = 25,
  sparsity = 1,
  min_occ = 2
)

Arguments

dtm

A DocumentTermMatrix.

term

A reference term appearing in dtm.

variable

An optional vector of values giving the groups for which most frequent terms should be reported.

p

The maximum p-value up to which terms should be reported.

n

The maximal number of terms to report (for each group, if applicable).

sparsity

Value between 0 and 1 indicating the proportion of documents with no occurrences of a term above which that term should be dropped. By default all terms are kept (sparsity=1).

min_occ

The minimum number of occurrences in the whole dtm below which terms should be skipped.

Value

A list of matrices, one for each level of the variable, with columns:

  • "\ in documents where the chosen term is also present.

  • "\ where the chosen term is also present (rather than in documents where it does not appear), i.e. the percent of cooccurrences for the term..

  • "Global \ in the corpus (or in the subset of the corpus corresponding to the variable level).

  • "Level": the number of cooccurrences of the term.

  • "Global": the number of occurrences of the term in the corpus (or in the subset of the corpus corresponding to the variable level).

  • "t value": the quantile of a normal distribution corresponding the probability "Prob.".

  • "Prob.": the probability of observing such an extreme (high or low) number of occurrences of the term in documents where the chosen term is also present, under an hypergeometric distribution.

Details

Co-occurrent terms are those which are specific to documents which contain the given term. The output is the same as that returned by specific_terms.

Examples

Run this code
# NOT RUN {
file <- system.file("texts", "reut21578-factiva.xml", package="tm.plugin.factiva")
corpus <- import_corpus(file, "factiva", language="en")
dtm <- build_dtm(corpus)
cooc_terms(dtm, "barrel")
cooc_terms(dtm, "barrel", meta(corpus)$Date)

# }

Run the code above in your browser using DataLab